In perfect theory, fire requires three things in adequate proportion: Fuel, heat, and oxygen. Take any one away, and the fire is supposed to extunguish (or at least become much less intense).
The "fire triangle" was replaced a number of years ago by the "fire tetrahedron." That is, the triangle is fuel, heat, and oxygen. The tetrahedron is fuel, heat, oxygen, and the chemical reaction of pyrolosis (fire). Interrupt any one of those four and the fire may be terminated. Halon interrupts the chemical reaction.
Firewall cutoff selected, the fuel is no longer supplied to an engine fire. Aside from the gasoline, which you have now turned off, there's not supposed to ba any other exposed fuel up there. Master off, the heat is no longer supplied to an electrical fire.
With fuel shut off, the engine still has oil. An oil fire is very difficult to control, even with an onboard fire system.
Electrical components burn, and are ignition sources. So long as the engine windmills, generally the generator still turns. If a fire has occurred, one may nor may not be able to interrupt the field, and one may or may not be able to ground a magneto through the cockpit controls. One may still have an ongoing source of electricity out there, and therefore, ignition.
For aircraft using hydraulic sources (such as the Twin Commander discussed in a recent thread, this presents another fire hazard at the engine.
Turbochargers present special hazards, and gas path leaks can cut through nearby components, leading to a fire, just as oil supplied to the turbo bearings can cause a fire.
Anybody knows how fast an Avgas/Air mixture flame front spreads?
In flight, that really depends on the fire and it's source and the location, as well as the amount of oxygen being put to the fire. An airborne fire can move very rapidly.
Oh, and there's a neat invention called a firewall. It's designed to stop an engine fire from spreading into the cockpit. Works fine as long as you remember to seal it properly - some aircraft may have vent holes or other holes through them, which may require separate actions to close.
Firewalls are required to be fire resistant, but it's a mistake to think it will stop a fire from reaching the cockpit. Works fine for a small, quickly extinguished fire, perhaps. Beyond that, don't count your chickens before they hatch.
Of course, if the fire is somewhere other than ahead of the firewall, the firewall is irrelevant.
A lot of pilots in the US carry guns for personal protection but in all my life I have never heard of a euthanization prompted by a cockpit fire. I'm sure it happens, but is extremely rare.
Say again?
Very few pilots in the US carry firearms while flying. A select few pilots operating in the airline environment carry firearms as part of the Federal Flight Deck Officer program, but that's very controlled, and there aren't a lot of participants.
Pilots shooting themselves to escape a fire? You've been watching too many movies.
Regarding the theoretical engine fire risk, I saw a movie about WWI biplane pilots a couple years ago (I think it was called "Flyboys" that) covered the cockpit fire topic. What all of those pilots would (very wisely I may add) do is carry a sidearm with them. This sounds barbaric, but they cleverly explained that the parachute had not been invented yet. So, if you caught fire, as would often happen back then, you would burn to death, which was apparently an excruciating way to go. Instead of burning to death, most pilots would draw their pistol and euthanize themselves before the pain got too intense. This happened to one of the pilots in the movie. It was somewhat sad to see, but it worked perfectly. The thing that was stresed is that the pilot's life ended when the fire started, not when he pulled the trigger, so he and his family would not be disgraced from stories of a suicide.
As you noted, that was fiction; a movie. The point of that element of the movie wasn't that parachutes hadn't been invented. They had. It wasn't that they weren't available. They were. The airplanes burned quickly because they were fabric and the dope was very flammable. So was the gasoline. As far as handguns go, there are recorded incidents of pilots shooting at one another with handguns in flight, and there's even a case of a T33 pilot who shot holes in his tip tank to balance a fuel load. The notions in the movie were melodrama and hollywood. Best not to confuse them with the realities of flying an airplane.
While you could, in theory, still burn to death, the chances of a cockpit fire are a LOT smaller today, and we now have checklists for it...pulling avionics fuses, using an extinguisher, diving to choke-out the fire, ect.
There are very few potential opportunities to fight a cockpit fire by diving an airplane.
When it comes to fire procedures, one needs to know one's airplane well and follow the procedures set out for that airplane with a keen eye to systems knowledge and understanding. What works in one airplane may prove fatal in another. Don't plan on blanket fixes, and don't mix procedures from one aircraft to another.
I always have a small bet with myself when PPRuNe parachute threads emerge as to how long it takes before the Gupster manages to introduce the topic of guns (he didn't disappoint this time round) but I'm still struggling with your assertion of in almost all cases.
It's hard to lose when you bet against yourself.