That's the reason. You don't leave fuel in the engine.
I was always taught to shut off all electrical before shutting down the engine, maybe something about a surge. I think this is more likely on startup though.
I shut off radios, master & alternator, mixture, then mags.