Light-induced collapse of metastable magnesium complexes formed in helium nanodroplets