SPOILER ALERT: This story contains details of tonight’s Castle series finale.

Richard Castle shadowed Kate Beckett to the very end, as Castle‘s series finale found Nathan Fillion’s wiseacre mystery novelist following Stana Katic’s common-sensical NYPD captain through one last trap, one last setup.

“Everything ends in tragedy, even an epic love story like yours,” says a villain to Castle.

Well, not so fast.

“Crossfire,” the name of Episode 822, brought an end to a lighthearted, featherweight crime series — Murder, He Wrote, in one of the show’s early jokes — that drew cult-level devotion from fans enthralled by its formulaic mysteries, breezy repartee and a central romance that wasn’t so much Will They/Won’t They as How Long/Can They.

Moving at the speed of an explosion, the finale kicked off with a big gun battle pitting Beckett and company against the mysterious and deadly LokSat gang of ex-CIA mercenaries, with Beckett and Castle rescued by a taco truck-driving Mason Wood (Gerald McRaney), Castle’s new buddy from the Greatest Detective Society.

Soon enough, Beckett reveals that she and Vikram (Sunkrish Bala) had been in cahoots with newly dead Caleb Brown (Kristoffer Polaha) in a scheme to learn the identity of the deadly LokSat leader. With Castle stuck in a safe house with daughter Alexis (Molly Quinn), mom Martha (Susan Sullivan) and sharpshooter Haley (Toks Olagundoye), Beckett sets out to face the evil-doer on her own, more or less.

Castle makes yet another in a long series of dumb moves by leaving the safe house, getting in a cab driven by the murderous Mr. Flynn (Jed Rees) and injected with a deadly truth serum. “I need a miracle, guys,” Beckett says to Detectives Esposito (Jon Huertas), Ryan (Seamus Dever) and Vikram.

In a twist that must have tickled the show’s writers as they wrote it, Mr. Flynn begins asking the doped Castle questions about his love for Beckett — a nifty way for the show to please its romance-loving fans — all while leading up to the Big Reveal (and SERIOUSLY, if you don’t want MAJOR SPOILERS, quit reading): the mysterious LokSat is none other than Mason Wood. Well, mostly, anyway (we’ll leave the final twist unspoiled).

For a show that loves the devilish and silly humor of the romance mystery genre, the Big Reveal was a hoot, a play on McRaney’s best-known good-guy role from the ’80s hit Simon & Simon. Better still, the former hero socked Castle where it hurt most — by forcing the drug-weakened novelist to betray those he loves.STANA KATIC

The finale, written by showrunners Alexi Hawley & Terence Paul Winter and directed by Rob Bowman, comes just a week after ABC announced it had canceled the show after eight seasons, a surprise to fans already miffed – see Deadline commenters’ reactions here – by last month’s revelation that Katic’s contract had not been renewed. (Original cast member Tamala Jones, who played medical examiner Lanie Parish, also wasn’t coming back — and she didn’t get much time or love in this finale episode). Hawley and Winter released a statement thanking fans tonight.

The original plan was to have Fillion and co-stars Seamus Dever and Jon Huertas return for a retooled (and possibly shortened) Season 9. Hawley and Winter had sketched plans for a Kate-less series and reportedly shot an alternate ending that would have set up a new season. After watching tonight’s episode, it’s easy to see where the simple changes could have been made: Following a particularly shocking shoot-out, the episode coda flashes forward seven years to reveal what a happy family the couple has become, complete with some new additions.

CastleBut whatever mysteries-of-the-night were solved in this finale, they were of distant interest to the show’s longtime watchers. Castle‘s weekly crime doings were non-taxing and easy-to-assemble puzzles, jaunty (if occasionally bloody) contrivances that this season included a jokey El Chapo-like drug lord, a hunt for Aladdin’s lamp and a cutthroat a cappella singing competition. None of it ever really pretended to be more than an excuse for chummy banter among co-workers (including Jones’ medical examiner and the cops played by Dever and Huertas), family (Quinn and most happily the imperial Susan Sullivan) and, most especially, the central romantic duo.

From the first season, when the goofy, bestselling mystery novelist Castle was foisted upon the more sober-minded (at least initially) NYPD detective Beckett to solve crimes – best not to ponder that one too hard – the two were headed for one place and one place only, and by Season 5 that’s exactly where they woke up. Despite some Etch-a-Sketching – the duo feared their romance would buck police department protocol, and perhaps producers feared the Moonlighting Curse of happy couples – Castle and Beckett, or CASKETT to fans, never really seemed seriously threatened by whatever new tribulations and old lovers came their way. They survived a TV marriage, even when their series couldn’t.