Smoke is normal in an electric oven, but flames are definitely not.
In order to start a fire, you either need a spark, or you need to heat something beyond its autoignition temperature (AKA kindling point). You might have had a short - or you might actually be using a gas oven with spark ignition - but I'm guessing your issue was the latter.
Cooking oil or grease being heated beyond its autoignition point is one of the most common causes of kitchen fires (grease fires). Supposedly, some oils have autoignition points as low as 550° F (or 288° C), though I'm not sure which oils those are. Olive oil would be my guess as the lowest, but pepperoni grease could very well have ignited at self-cleaning temperatures (which, as you noticed, go up to nearly 1000° F).
Fortunately for you, all modern ovens have a mechanical interlock which prevents them from being opened during a self-cleaning cycle. If you'd opened it, you would have made the problem a lot worse by (a) supplying the fire with abundant oxygen, and (b) drawing all the hot air and flames out of the oven and into your kitchen, quite possibly setting your whole home on fire. Heat wants to move to where it's cold; that's why you keep your doors and windows closed in the winter.
There are a multitude of oven cleaners available for self-cleaning ovens - you are supposed to use these before you run a self-cleaning cycle. Yes, I know it's odd, but "self-cleaning" doesn't really actually mean that it cleans itself, it just gives you a little extra help. You need to try to clear out all the grease and big chunks of food first using one of these cleaners, then run the self-cleaning cycle to deal with anything you might have missed.
What you need is to deflect the heat from the top of your pie. If you have two racks in your oven, and can position them so that the pie is in the middle with a rack above it, place a piece of aluminum foil directly above the pie. Another option would be to set a piece of foil on top of the pie after it has partially baked. Either way will protect the top from direct heat, allowing the ambient heat to penetrate and bake the whole pie.
Best Answer
Bicarbonate of soda is the most effective agent for removing odours in my experience.
I've used it to detox a fridge that stank of fish after I accidently left fresh seabass in there before going off on holiday.
Just scrub it in using a scourer and warm water, followed by a thorough rinse.