They may not have always come from the greatest shows, but these farewell episodes left us with plenty to remember.

Series finales are fickle things. Some of them have the power to redeem an entire show, to reframe the audience’s perceptions of what came before. Those massive twists rarely land, so more often than not, TV shows end not with a bang, but with a melancholy whimper.

And then there are the other times when a big series finale swing goes so awry that it can undo many seasons’ worth of goodwill. Recency bias rears its ugly head and some lifelong fans use these last episodes as a reason to sour on a particular show.

That’s why that the best finales don’t always come from the best shows. “Battlestar Galactica,” “How I Met Your Mother,” “Dexter,” and more often reached brilliance over the course of their runs, but rang less true with their final notes. Some of IndieWire’s choices below come from shows that wouldn’t normally rate as highly on lists of Great TV Dramas/Comedies.

But each of these picks left viewers with something meaningful that went above the rest of the show that came before it, all to make something worth remembering. The IndieWire picks for the best TV closing episodes of the century are below.

(It goes without saying that the reasons for our choices get well into spoiler territory, so consider yourself warned.)

24. “Spartacus: War of the Damned”

“Spartacus” had a fairly rocky start, but by the time the first season wrapped up with the stunning “Kill Them All,” it was evident that the series had found its groove. With just a fraction of the budget of the major networks, the series carved out its own visual style and consistently delivered battle sequences on an epic scale. It saved one of its best battles for last, pitting Spartacus and his remaining rebels against the Marcus Crassus-led Romans. The battle was beautifully choreographed and filmed, but it succeeded on such a scale because it was driven by raw emotion. Even though history dictated the outcome of the battle, we couldn’t help but hold our breaths, hoping Spartacus would somehow defeat Crassus even as it became clearer and clearer that he wouldn’t. However, the series still ended on a moment of quiet celebration, assuring us that Spartacus’ legacy would never fade.

23. “Person of Interest”

“Person of Interest” began as a typical crime procedural, but it ended as a complex, serialized science fiction show that found the humanity within technology. Though the finale had no shortage of action, it tied up the series so well because it focused on the reflective moments in between. The Machine’s ruminations on death and legacy took center stage, highlighting the connections that were forged and people who were saved over the show’s run. Reese’s sacrifice on that rooftop was a fervent expression of the very essence of the series: the impossibility of severing the human from the machine. It wasn’t just about The Machine or Samaritan. It was about the humanity that endured, even if the physical bodies were no longer with us. Who wouldn’t want Amy Acker around forever, anyway?

22. “Sex and the City”

Is a finale still a finale when it’s followed up by two movies (one great, the next awful)? In short, yes: Just like any series finale could suddenly become just another season finale if the Revival Fairy comes a-callin’, the O.G. “SATC” ending is still the best. After making audiences believe Carrie’s (Sarah Jessica Parker) fate was tied to turbulent Russian artist Petrovsky (Mikhail Baryshnikov), the two-part finale sets up a romantic wooing that’s trickier than it seems after the first half-hour. Yes, Big (Chris Noth) is on his way to Paris to win back the woman of his dreams, but how can a seven-year on-and-off romance be resolved in less than an episode? How can Carrie be ready for a man the audience couldn’t agree she even wanted? Then there’s the slap, which not only crosses a whole bunch of lines, but wakes Carrie up to the reality of her situation. She’s not meant to be with Petrovsky and just as importantly, she’s not meant to be in Paris. “Sex and the City” made Big even bigger in its final episode, as he came to represent the city of New York and all of Carrie’s deepest loves. It resonates, and so does the finale — even after that second movie.

21. “Justified”

“The Promise” didn’t strive for a huge, climactic finale. It worked because it stayed true to the series, which made a name for itself by tackling big questions in a suave, laidback manner. A chief question of the final hour was whether or not Raylan Givens would be able to leave Harlan alive, literally and figuratively. The answer to both? Yes. The series concluded his story by allowing him to unshackle himself from his past, moving beyond Arlo’s shadow and away from Boyd’s life of crime. The real gem of the finale was seeing Raylan and Boyd reunite four years down the road, smiling at each other from opposite sides of a prison glass window. After all, they were always meant to be. In a series that prided itself on its dialogue, the line that resonated the most was the one that brought it all full circle: “We dug coal together.”

20. “Dollhouse”

Fox TV/Kobal/REX/Shutterstock

While the Joss Whedon series began with a problematic tone — framing the “doll” operatives as if they were some idealistic super spies or fantasy wish fulfillment — once the show shifted to take a stance against such human trafficking and abuse, it started to get good and explore deeper themes about identity and humanity. Some of the series’ most emotionally honest episodes occurred in Season 2 (see Dichen Lachman’s turn in “Belonging”), when the show began to widen the scope of its storytelling. Which is why it’s a shame that this was its last season.

In “Epitaph Two: Return,” the show flashes forward to the bleak future seen in the first season’s unaired episode “Epitaph One,” in which the city is a war zone in ruins. Battles ensue, sacrifices are made, and even a secret love child is revealed. What saves this from dystopian soap — dysoapian? — are the technologically satisfying endings: one that reverts each doll to their original personas, and a bittersweet one that pre-dates “Black Mirror’s” concept of taking on a loved one’s persona into oneself, never to be parted. “Dollhouse” may have had its issues, but it proved right through to the end that it was a fertile playground for strange and innovative ideas.

19. “30 Rock”

There’s so much packed into this last installment, which manages to establish emotional denouement for nearly every character of the show’s ensemble. But there are two reasons it had to make this list. One is the slightly silly but also profound final scene, which pays off years of joking about Kenneth the Page’s immortality while also bringing things around full circle in a deeply satisfying way. But more importantly, there’s the final confrontation between Liz (Tina Fey) and Tracy (Tracy Morgan) at the strip club they visited during the pilot, which is a scene that lingers in the memory, as a beautiful and honest acknowledgment about how adult relationships work, especially at the workplace.

“We were forced to be friends because of work. And we’re probably not gonna hang out after this, all right? You’ll say that you’re gonna invite me to your house, and it’s never gonna happen,” she says. “Tracy, you frustrated me, and you wore me out. But because the human heart is not properly connected to the human brain, I love you, and I’m gonna miss you.” With those words, Fey reminded us that the ending of things, whether it be shows or relationships, doesn’t diminish them, and that the real tragedy would be in refusing to let something go.

18. “Man Seeking Woman”

A show that already had a specific brand of melancholy romantic foibles made the leap in its third and final season when the adventures of Josh gave way to the adventures of Josh And Lucy. Both Jay Baruchel and Katie Findlay sent off their characters in style in a wedding episode that captured all of the anxieties of commitment and family and the future all at once. It may not be the best episode of the season (that honor goes to the proposal episode “Bagel,” which made IndieWire’s list of the Best Episodes of 2017). But this farewell gave such a grounded acknowledgment that even life in a fantasy world, the real value comes in who’s fighting those battles alongside you. After a series run that found some of the best ways to stick some real human moments in the absurd, the series’ final moment, of the two kissing in a bright ray of sunshine in the middle of a rainstorm, is a beautiful little allegory to end with.

17. “Life on Mars” (U.S./UK)

We’re lumping the British series and its American spin-off together on this list, but to be clear: They’ve each earned this mention for very different reasons. The original series, which ran for just two seasons, was the perfect length and ended with a perfectly executed finale; after 16 episodes, the show had revealed the true reason why Sam Tyler (John Simm) had been sucked back in time to 1973, and also made it very plausible as to why (and how) he might wish to return to that era. It’s both dark and hopeful, a happy ending that represents a fascinating level of bleakness, and also still features plenty of Gene Hunt (Philip Glenister) being the magnificent bastard we came to love.

Meanwhile, the U.S. version premiered after the end of the UK series, and though American audiences might not have been familiar with the original version, the writers certainly were — and clearly felt the pressure to do something different when it became clear the show would not be returning for a second season. And holy crap, did that series finale take a different approach. Honestly, it’s something you literally have to see in order to believe. Just know that as bonkers as you might predict it to be, the American “Life on Mars” finale will exceed those expectations. And we admire the hell out of it for trying.

Sign Up: Stay on top of the latest breaking film and TV news! Sign up for our Email Newsletters here.