When the pilot light on a water heater will no longer stays lit, it typically means the thermocouple is bad. Thermocouples are little electric generators that create a magnetic current that holds open a magnetic gas valve inside the control unit on the front of the water heater. If the generator or the wiring from the unit can no longer sense heat at the pilot, it will constantly shut it off. Replacing the thermocouple will generally solve the problem. Each water heater thermocouple comes with instructions. Make sure you read them thoroughly and follow all safety guides.