The direct answer
Your pilot lights, burns while you hold the knob, then dies the moment you let go. That's the classic thermocouple story, and it's true maybe seven times out of ten.
The thermocouple is a pencil-thin metal probe that sits in the pilot flame. When it heats up, it makes a tiny electrical signal that tells the gas valve, "the flame is real, keep the gas flowing." When it weakens, the valve stops trusting it and shuts the gas off. Pilot dies.
The second most common cause is a dirty pilot orifice. After a furnace sits idle all summer, dust and cobwebs choke the tiny opening, the flame goes weak and yellow, and it can't heat the thermocouple enough.
Good news: both are cheap and mostly DIY on a standing-pilot furnace. A pro visit runs $150–$700, mostly because they may find the gas valve is the real problem.
What's actually going wrong
Think of this as a short chain: gas gets to the pilot, the pilot flame heats the thermocouple, the thermocouple holds the valve open. A break anywhere in that chain drops the pilot.
Start at the thermocouple because it's the weakest link by design and the cheapest to replace. These probes just wear out. Ten to fifteen years is a normal lifespan, and a lot of standing-pilot furnaces are well past that.
If a new thermocouple doesn't fix it, back up to the gas flow. A partially clogged orifice starves the flame. You'll see a lazy yellow flame instead of a crisp blue one, and it won't wrap the thermocouple tip the way it should.
The connection point matters too. The thermocouple screws into the gas valve with a small nut, and if it's loose (common after any past service work), the signal gets weak even when the part is fine.
Drafts are the sneaky one in summer. An open basement window, a running dryer, or a bathroom exhaust fan can pull enough air through the space to snuff a small flame. If your pilot flickers visibly, look for airflow before you condemn any parts.
The gas valve itself is last on the list because it's the most expensive and the least likely. When the magnetic coil inside weakens, no thermocouple on earth will hold it open. That's a pro diagnosis and often a replace-the-furnace conversation.