For spin-based quantum computation in semiconductors, dephasing of electron spins by a fluctuating background of nuclear spins is a main obstacle. Here we show that this nuclear background can be precisely controlled in generic quantum dots by periodically exciting electron spins. We demonstrate this universal phenomenon in many-electron GaAs/AlGaAs quantum dot ensembles using optical pump-probe spectroscopy. A feedback mechanism between the electron spin polarization and the nuclear system focuses the electron spin precession frequency into discrete spin modes. Employing such control of nuclear spin polarization, the electron spin lifetime within individual dots can surpass the limit of nuclear background fluctuations, thus substantially enhancing the spin coherence time. This opens the door to achieve long electron spin coherence times also in lithographically defined many-electron systems that can be controlled in shape, size and position.