Tightrope
(1984)

The killer is discovered to be Leander Rolfe (Marco St. John). He was an ex-cop who had recently finished an eleven-year prison sentence for raping two teenagers, and Wes (Clint Eastwood) not only worked with him on the force but was also the one who arrested him. This explains why he was killing Wes’ acquaintances, prostitute and otherwise, when he saw Wes was onto him, and almost killed Wes one night.

While the police are staking out Leander’s apartment one night, Leander goes to Beryl’s (Geneviève Bujold) home, killing the cops guarding it and almost killing Beryl, but Wes – who knew something was wrong there when he tried to call the cops there and got no answers – arrives in the nick of time, causing Leander to retreat. Wes chases him all the way to the train yard, and in the ensuing fight Wes kills him by putting him in the path of an oncoming train.

As other cops arrive at the scene, a tired and shaken Wes wanders up the tracks, where Beryl eventually greets him, and they walk off together for elsewhere.

Thanks Tornado Dragon!