There may be two different problems here.
Backfiring is normally due to unburned fuel accumulating in the exhaust system until conditions are right for it to touch off. Paradoxically, it is commonly caused by running too LEAN--the spark plug fails to ignite the too-lean mix, which is then swept out into the exhaust. Could be either a vacuum leak letting too much air into the mix, or carb set too lean. In that brief time between gears, the engine is still trying to fire on every compression stroke BUT, with your foot off the gas pedal, the idle jet can't provide enough fuel to support the high-rpm combustion needs. EIther way, opening the GAV should help temporarily.
The backfiring at shut off may be due to a leak at either end of exhaust manifold allowing fresh air for combustion to be drawn in as system starts to cool down. Retarded timing or anything else that overheats exhaust system will aggravate the situation.
If the problem is electrical, it will show up as backfiring under load.
Steve