We study theoretically the tunnel ionization of quantum-well excitons localized in a lateral electrostatic trap. Such traps were realized in a quantum-well system with top metal gates in recent experiments. We show that a strong confinement of excitons leads to fast tunnel ionization. This tunnel ionization of excitons results in quenching of the photoluminescence in the case of a strong modulation of the electrostatic potential. Our model calculations show that a magnetic field normal to the plane of the quantum well will strongly stabilize the excitons. Furthermore, the character of the exciton stabilization by a magnetic field depends on the symmetry of the trap. In particular, in zero-dimensional traps we predict that the localized excitons become completely stable when the magnetic field exceeds a critical value.