The pilot light will always remain on in a gas oven that is working properly. The oven will turn off while still in use if the pilot light blows out due to improper venting. This tends to be the case if the oven is newly installed.
The thermostat is the mechanism in the gas oven that tests the temperature of the oven and supplies the pilot light with gas. If the thermostat is broken, it might turn off while the oven is in use and will not supply the pilot light with enough gas. In this case, you must replace the thermostat.
The pilot will blow out or won't be able to turn on if food splatters on it. The food residue will prevent the pilot from automatically relighting while the oven is in use. Turn the oven off and let it cool completely. Clean the pilot light with a dry brush.
Each gas oven is fitted with an oven safety valve that will shut off the oven if it gets too hot or continues to emit gas without a light. Sometimes, however, the oven safety valve is defective, and it turns the oven off even if there isn’t a safety issue. Replace the valve if this is the case.