Optical quenching of metastable magnesium