Gas ovens installed on ranges have thermostats to stop heating when needed, and systems that use pilot lights have thermocouplers that shut off gas if the pilot light goes out. Newer gas ranges typically have several thermal fuses that stop gas if high levels of heat are detected.
Cooktops on ranges typically don't have thermostats, as the heat is applied to the cooking vessel, not the cooktop. As a result, the only part that heats on the stove is the burner covers, which are designed to handle far higher heat levels than flames can produce. However, thermal fuses can detect if the oven or the stove itself is overheating, which might represent a fire risk. Broken thermal fuses require replacement, since they can't be reset.