Here's my take on it.
There are 2 parts to a key press. There's the initiation, and the release.
View sideways with your hat and open a chat buffer before you let go. Now no matter what you do your head is stuck sideways until it gets a "side view OFF"
You do this by putting "side view ON" again (you move your hat in the same direction) and then let go. Once you let go "side view OFF" triggers and it stops sticking.
You have a macro/program set. You need to build a timer or delay into it, or something, between the "fire secondary" (dropping the tank) and the "toggle secondary"
The "fire secondary ON" is read, but before the "fire secondary OFF" the "secondary select ON" and "secondary select OFF" are initiated. So no "fire secondary OFF" is ever received.
Short way to fix it, hit secondary fire again and let go. Stop it from happening by redoing your macro/stickmapping to allow it sufficient time between commands.
I recall one mapping software I had distinguished between fire+ and fire-, + being downstroke, - being upstroke. If yours does this, make sure you choose on then off, as different steps.