
Many people do not bother to teach a horse not to be barn sour until they are returning to the barn after a long trail ride with friends. It can be done this way, but it is certainly the more challenging way to teach a horse this particular lesson.
For me, it is much easier to fix barn sourness, by dedicating specific lesson times to this difficult problem. It is interesting that, as riders, we will spend weeks, months, and even years, teaching horses so-called natural movements, like piaffe, and passage, but expect a horse to learn something
unnatural like trailer loading, or non-barn-sourness by simply asserting that it should be no big deal.
A problem of this sort can become fairly serious and the longer you wait to fix it, the harder it will become. I have found that the easiest way for me is to take the horse out by myself or with a willing companion who understands that we are not going for a fun trail ride. We are going for a TRAINING ride. In fact, I go on a training trail ride with friends and students every few weeks. We go out on a ride dedicated to the training of the horses and there is no expectation that we will complete any loop, circuit, distance or anything like that. Everyone brings their problem horses and we work together to fix those problems. This we do as a group every couple of weeks, but if I really have a barn sour horse, I dedicate a portion of everyday to this problem until it is gone. Then I use the occasional group training trail ride as a maintenance exercise.
When I have the horse out ready for his training, I ride out from the barn or the trailer as the case may be, and ride only a short distance. Then I run the horse back to the barn and when I arrive, I work the horse heavily for 3 minutes. (Get a kitchen timer to make sure if you don’t already have one.) Then I walk the horse back out on the trail. I ride the horse a little further than I did last time. Then I turn around and start riding back to the barn. If the horse starts to jig or pick up speed, I run the horse even faster back to the trailer and when I arrive, I work the horse heavily again for another 3 minutes. Then I walk the horse back out onto the trail. And of course I go a bit further. When I get to some arbitrary turn around point, I dismount, loosen the girth, and let the horse graze. Bring a halter to put on so you can even remove his bridle. Let the horse graze for 3 minutes. Then tighten the girth, put on the bridle, and ride him back to the barn. If he starts to pick up speed, run him back to the barn and work him hard again for 3 minutes and then bring him back out onto the trail.

Keep repeating this until he no longer starts to pick up speed on the way back. The first time he keeps his speed down on the way back, get off him immediately, loosen his girth, and let him graze for 3 minutes. Do NOT wait until you are back at the barn. Do it right on the spot.
This will teach the horse that returning to the barn does not necessarily mean that the work day is over. On the contrary, most of the time, it means that the hard work is just beginning. Furthermore, by stopping and grazing at the turn-around point, or wherever he decides he wants to slow down, he learns that the more calmly and more slowly he goes to the trailer, the sooner he gets the benefits of being at the trailer. The light bulb will go on when he realizes that he does not even need to be at the trailer to receive benefits.