We propose a new mechanism for stabilization of confined modes in lasers and semiconductor microcavities holding exciton-polariton condensates, with spatially uniform linear gain, cubic loss, and cubic self-focusing or defocusing nonlinearity. We demonstrated that the commonly known background instability driven by the linear gain can be suppressed by a combination of a harmonic-oscillator trapping potential and effective diffusion. Systematic numerical analysis of one- and two-dimensional (1D and 2