A topological characterization of stable rings