Ride the horse you have, not the horse you want. When he's going nicely, ride him nicely. When he starts his bs, don't argue with him but instead think of something quiet and easy and simple to do. When the going gets tough don't make it tougher by demanding more. Demand less. Expect less when he is in that state of mind. Be clear, simple, and listen for the smallest of effort on his part to do what you are asking.
Just relieve the pressure a little, and see how he responds.
You said when he flips the switch you get busy and do all these things to get him back with you. Why not try and do something more simple, as i said above, or doing nothing at all? Stand quietly there with him until you feel he is ready to relax and let go of his defenses.
Sometimes less is more.
In riding, a horse's energy is like a river- guided by the banks but not stopped by them.