Optical control of electron spin coherence in CdTe/(Cd,Mg)Te quantum wells