3:10 to Yuma
(2007)

Dan (Christan Bale) doggedly takes Ben (Russell Crowe) to the train to Yuma (where a jail and hanging await him), the only man who is willing to do so.  The two men bond and Ben comes to respect Dan, eventually helping him to evade his own men so that he can be put onto the train.  Ben gets into the prison cell on the train only to see Dan shot and killed in front of him.  Ben jumps off the train and shoots all of his men before getting back into his prison cell.  As the train pulls away Ben whistles to his horse who runs alongside the train - Ben has escaped from Yuma twice.  It is assumed that the Pinkerton man will hold to his promise to send Dan's son home with all the money needed to get their family out of debt.

Thanks Mary C!