More often than not, a "backfire" when shutting down is caused by glowing carbon in the exhaust system (piston, head, ex port, pipe, and muffler). As you turn the ignition off, and as the engine coasts to a stop, it is still taking in fuel and the unburned fuel is exiting out and into your muffler. The muffler "might" have glowing red hot carbon in it and a backfire is a result. Also check your exhaust manifold gaskets which might allow air to enter making a backfire even more prevelant.