For domestic purposes the best suited valve would be a capillary firevalve type, these are available in many lengths to fit most circumstances. These are fitted to the outside wall where the fuel line enters the property. Then the capillary tube runs through the building to the boiler where a sensor then monitors the temperature around the boiler, if it exceeds the set activation temperature then the valve on the wall outside is shut off.
Commercial/Industrial situations usually call for a larger firevalve system to be installed such as a drop weight firevalve, these employ a wire and pully system under tension connected to a fusible link that melts and allows the weight to drop on the arm and close the valve. These can also have various electrical components that can notify building management systems such as emergency lighting, doors alarms etc.