Depending on the model, it could just be dirty. The CO detector will turn off the gas if it does not read any oxygen nearby. It is a safety so if to much carbon monoxide builds up, it will turn off the gas.
Or it could be your thermocouple.
Read your manual to find a solution.