check the overheat stat as this also cuts of the gas valve. check also the thermostat on the boiler as it should cut the boiler off at certain temp. if its faulty the boiler will carry on heating causing the safety overheat to cut off the boiler. so it will be one or the other. hope this helps