I am very glad you weren't hurt. Coming off a galloping horse either from falling off or being bucked off can have serious consequences. I have had that happen to me and I still have marks on my leg from hip to toe black and blue and purple bruise.
It is the luck of the draw that you weren't hurt.
Galloping down a trail is a blast. I used to do it myself on my mare bareback when I was a teenager. But when I asked that mare to slow down she did - instantly. She NEVER ever bucked or acted a fool when I rode her. (geez...wish I still had Little Bit) If you don't have 100% control of the horse and 1000% know he will not buck I wouldn't race him EVER. Sometimes once you get that motor running it is hard to shut it off and be "just" a trail horse. Work him in a large arena or flat track to get the speed you want with the control you want and if he even gives you the feeling a buck is about to come your way do circles until he calms down.