Pilot lights are often designed so that the heat from the flame holds a bimetallic switch in the open position. Should the light go out, the bimetallic switch will shut as it cools.
TBF the amount of gas used in old style pilots is really tiny. I’m sure it’s possible to accumulate dangerous quantities somehow, perhaps in a sealed subterranean basement if using propane instead of natural gas.
Natural gas is mostly methane, which is lighter than air and easily escapes most structures.
Natural gas today is mostly methane, but in the past it often had large concentrations of CO. In 1950 you can turn the gas on and stick your head in the oven as a form of suicide - won't work anymore (unless you get the house to explode).
Fascinating. I double-checked with ChatGPT (FWIW), and it confirmed. It said that currently, natural gas is extracted and shipped in its mostly pure form. In the mid-20th century, natural gas was "town gas," manufactured by heating Cole in the absence of oxygen. That produced a lot of carbon monoxide.