Electra Glide in Blue
(1973)

Over the course of the movie, Wintergreen (Robert Blake) becomes sympathetic to the hippies that his fellow police officers have been hassling, and that detective Harv Poole (Mitchell Ryan) has been trying to pin the murder on. Wintergreen eventually proves that the murder victim was a drug dealer, and had been killed by Crazy Willie (Elisha Cook). He denounces Harv for stupidity and incompetence.
 
Wintergeeen also finds out that his partner and best friend Zipper stole money that had belonged to the dead drug dealer, and used the money to buy his own motorcycle. Wintergreen confronts a drunken ZIpper, who begins shooting his gun indiscriminately, hitting an innocent bystander. Wintergreen must shoot and kill his best friend.
 
Later, Wintergreen is back on highway patrol on his motorcycle. He pulls over a van for a routine traffic violation, then notices that the driver is one of the hippies Harv had harrassed earlier. Wintergreen feels bad about the way Harve treated the hippie, so he lets the driver and his passenger go free. Moments later, Wintergreen realizes that he forgot to give the hippie back his driver's license, so he drives up behind the van with his lights flashing, trying to get the driver's attention. The hippies in the van think Wintergeeen is going to bust them, so one of them (played by Terry Kath, guitarist and vocalist of the rock band Chicago) rolls down the window and blows Wintergreen away with a shotgun, killing him instantly.   

Thanks John L!