The magnet assembly is energized by voltage generated by a thermocouple that is heated by the pilot or burner flame. When this flame is extinguished, the thermocouple voltage decreases until a spring overcomes the magnetic force and closes off both the pilot and main gas. It can be applied to various commercial gas cooking appliances such as ranges, ovens, griddles, stock pots, grillers and wok ranges, etc.