Leg. Give them a bunch of leg because of a horse can stop and get it’s head between his legs you’re a goner. Better to let them bolt and have a fast canter then to buck you off.
With one of my old ponies they used to do the exact same thing. What worked with him was just doing a lot of trot to canter work and just relaxing until he stopped we also got his tack checked to see if it was fitted correctly and turns out it was slightly to small so we got it adjusted and then after a few weeks he stopped!
Hope this helps