telling him she could only think of him while on the verge of death and then they later kiss passionately. The thread of their relationship continues in Season 5, with Castle and Beckett trying (and mostly failing) to conceal their relationship from their co-workers – not simply because of office gossip, but the threat of a misconduct charge being levied by the ever-watchful Captain Gates. In episode 5.04 (Murder, He Wrote), Ryan accidentally stumbles on the truth while interrogating a suspect, but chooses to keep the truth to himself and respect their privacy. Lanie and Esposito learn the truth in the following episode when Castle was framed for murder (Ryan told Esposito and Beckett told Lanie so that they were aware of the fact that their background research would expose Castle's contact with Beckett outside of case-related matters). In the Season 5 episode "Still", Captain Gates reveals that she has known about the relationship and has kept quiet since to maintain "plausible deniability", i.e. she cannot report the relationship because she hasn't personally witnessed any behavior to suggest a relationship and is happy to keep up the plausible deniability so long as the pair remain professional on the job. In the season six episode "Veritas", after Beckett is framed for murder by the man who had ordered the death of her mother, Castle works to protect her. They are eventually able to clear her name and as a bonus, finally arrest the man Beckett had been after for so long with hidden evidence Roy Montgomery had left Johanna Beckett. In episode eleven of season 7, Castle is ordered to leave the NYPD due to co-operating with a mafia don to prove the innocence of one of his underlings suspected of murder, leading to the true murderer being assassinated. After being restored to his position in the police department, Castle is finally able to bring down old enemy Jerry Tyson, aka serial killer 3XK during "Resurrection" and "Reckoning." In the season seven finale, "Hollander's Woods", Castle is confronted with his past when a murder surfaces that matches one he saw in his youth. The murder he'd witnessed had been his inspiration to write as because he was never able finish the story of what had happened in the woods when he was a kid, he became driven to finish all the other stories he could find. The investigation leads them to