As MK said - the cause is probably unburnt petrol getting into the exhaust/silencer and then igniting when you restart. Another thing to check is that there are no air leaks on the exhaust - if it can suck cold air in you will get the same flaming affect (my CCM does it every time I shut the throttle due to the design of the exhaust system, it's not possible to seal it properly).
My ZX600 Ninja sometimes did the same with a loud bang. When stopped, you may have one cyl stopped where both the intake and exhaust valves are open. Any fumes from the carbs will pass through and collect in the exhaust.
The solution was to drill a 1/16" hole in the lowest point of the exhaust. As the gas fumes are heavier than air, it will drain out the hole.