Explanation:
Atoms typically prefer having filled valence orbitals. In a chlorine atom one electron is necessary to have a filled valence orbital. This explains why the electron affinity for Chlorine is so exothermic, since chlorine wants a filled valence orbital. Magnesium on the other hand wants to lose 2 electrons in order to resort to its 2nd energy level with a filled orbital. This explains why magnesium has a desire to lose its electrons. Therefore, both magnesium and chlorine have filled valence shells when participating in a bond
note: I went a little overboard with this explanation... feel free to make any revisions.
Hope this helped, 2Trash4U