In contrast to the binary switchable mirror films (YHx, LaHx, REHx with RE:rare earth) which have a weak red transparency window in their metallic dihydride phase, rare-earth alloys containing magnesium are remarkable for the large contrast between their metallic dihydride and transparent trihydride phase. By means of structural, optical transmittance, and electrical resistivity measurements on a series of Y1−yMgyHx, films we show that this is due to a disproportionation of the alloy. While the yttrium dihydride phase is formed, Mg separates out, remaining in its metallic state. Upon further loading, insulating MgH2 is formed together with cubic YH3−δ. In this way Mg acts essentially as a microscopic optical shutter, enhancing the reflectivity of these switchable mirrors in the metallic state and increasing the optical gap in the transparent state.