This paper applies mean field game theory to dynamic demand management. For a large population of electrical heating or cooling appliances (called agents), we provide a mean field game that guarantees desynchronization of the agents thus improving the power network resilience. Second, for the game at hand, we exhibit a mean field equilibrium, where each agent adopts a bang-bang switching control with threshold placed at a nominal temperature. At the equilibrium, through an opportune design of the terminal penalty, the switching control regulates the mean temperature (computed over the population) and the mains frequency around the nominal value. To overcome Zeno phenomena we also adjust the bang-bang control by introducing a thermostat. Third, we show that the equilibrium is stable in the sense that all agents' states, initially at different values, converge to the equilibrium value or remain confined within a given interval for an opportune initial distribution.