Pretty big stuff going down. It would've carried more weight if the captain had really been a significant character all along rather than just an authority figure who occasionally has a few lines. The fact that Montgomery was so prominent throughout this episode pretty much telegraphed that he was either going to a) get killed, b) turn out to be part of the conspiracy, or c) both. And the way the camera focused on Montgomery when Castle started talking about the third cop, plus the look on Montgomery's face, was kind of a dead giveaway.
Although I'm glad they established that he wasn't the archvillain so much as someone who'd made a terrible mistake and been paying for it ever since. I can't quite say he went out as a hero, since he drew the others in with the specific goal of killing them rather than arresting them, and shot first without warning, which is premeditated murder, not self-defense. I think such means taint the ends. Still, at least he was trying to protect Kate and make amends for his past mistakes.
I hope the new captain next season is a woman. Just for a change of pace.