backfires when i turn key off

When you turn the key off it drops the field in the coil causing it to to fire any random plug at any random place in the timing.
Unburned fuel in a cylinder will fire if it's the cylinder that got the random spark.
I have my timing advanced right to the edge, and my engine will do that once in awhile.
If it's popping back through the intake when you shut it off, try backing the base timing a little.

Maybe?