And sure enough, the movie playing at the theatre is Blazing Saddles, the same one we're watching at this moment.
Hedley runs into the movie theatre, buys a snack, and takes a seat while the feature plays.
On the screen, we see Bart arriving at the movie theatre, which tells Hedley to run for it. Outside, Bart catches Hedley and tells him his day has come.
But Hedley wants to settle their score like men, so Bart puts down his gun and tries to fight Hedley. But then Hedley reveals that he had a gun all along. Bart rolls out of the way in time and shoot Hedley in the groin. Tee hee hee.
Now that Hedley is done for, Jim and Bart head into the theatre to watch the end of the movie.
On the screen, we look back at Rock Ridge, where the people are asking Sheriff Bart to stick around. But Bart says he's needed elsewhere and can't stay. He makes a passionate final speech and rides away, but not before the people call him out for being full of it.
In any case, Bart rides away and stops to say goodbye to Jim. Then he changes his mind and invites Jim to ride away with him.
In the final shot, we see Jim and Bart ride off into the desert until they reach a limousine. They get off their horses, jump into the car, and ride away.