Did it have fuel stabilizer in it while it was sitting for a year? Even if it did, my first suspicion would be that the carb is fouled. But usually that doesn't lead to backfiring, just not starting. On the other hand, the backfiring did start when you turned off the gas. If it was timing related, a valve, etc, curious that it started just when fuel was shut off. I suppose the float could be stuck open flooding it badly.
After checking the spark plug condition and for spark, I'd pull the carb and rebuild it. If you get a service manual it should be fairly easy. By taking it apart, you can completely clean it and remove any gunk. The rebuild kits are cheap, look on Ebay. I got one for a Tecumseh engine for ~$12.