I'd add
stateTransitionOnTimeout[4] = "Fire";
stateTimeoutValue[4] = 0.1;
This should make it that when it reaches stage 4 it loops back to stage 3 (fire) in 0.1 seconds and then if it reaches stage 4 while the mouse isn't down, it should go on to stage 5 and stop firing. Unless releasing the mouse in stage 3 causes an infinite firing loop, you should be good to go (I assume it wont though)