When the flame is alight, the safety valve is pulled back by the coil, and the gas can flow. If the flame is extinguished, the safety valve is immediately closed by the spring, as there is no longer any magnetism.