The paper proposes a mechanism for real-time pricing of electricity in smart power grids, with price stability as the primary concern. In previous publications the authors argued that relaying the real-time wholesale market prices to the end consumers creates a closed loop feedback system which could be unstable or lack robustness, leading to extreme price volatility. In this paper, a mathematical model is developed for characterization of the dynamic evolution of supply, (elastic) demand, and market clearing (locational marginal) prices under real-time pricing. It is assumed that the real-time prices for retail consumers are derived from the Locational Marginal Prices (LMPs) of the wholesale balancing markets. The main contribution of the paper is in presenting an effective stabilizing pricing algorithm and characterization of its effects on system efficiency. Numerical simulations conform with our analysis and show the stabilizing effect of the mechanism and its robustness to disturbances.