The other times he did it this week, all it took was a smack with the reins (they're soft reins — it didn't hurt him, just got his attention) and some firm steering and he gave up. I've been working on the things we did with the trainer but not for as long a session, and it's going well.
I think it's just exactly what you all have said: he listens usually, but I don't have his full attention, so when there's a distraction, I lose him. I definitely feel like we're going to get through it, though.
Another rider ( the owner if the horse I leased before I got Sam) said something that made sense, too. She said horses follow their leaders, so if you're riding and a horse tries to follow other horses out if the arena or focuses on anything but you, you're not the leader, and when you are, the horse looks to you for security and therefore would rather follow what you're asking than the other horses. As I've said, leadership is not natural for me, but I'm really hoping I can get there!