The “Crazy Ex-Girlfriend” series finale ended, literally, on a high note, with Rebecca Bunch (Rachel Bloom), her face glowing, her friends gathered around her, about to burst into song—but this time for real. Until then, all the music we’d heard—a thrilling, funny, often profound collection of original songs, which ranged from hip-hop pastiches to Sondheim parodies—was all in her head, maybe as part of her borderline-personality disorder, but definitely as part of her personality. “When I stare off into space, I’m imagining myself in a musical number,” Rebecca shyly confessed, in the episode’s key breakthrough. “And, because I do that, so does the show.” Then, in the sort of wry, have-it-both-ways meta-gesture native to the series, she added, “And by ‘the show’ I mean the very popular B.P.D.-workbook acronym Simply Having Omniscient Wishes.”

When “Crazy Ex-Girlfriend” first débuted, a lot of people complained about that title: so harsh, so mocking, maybe kind of sexist? Who exactly was being made fun of? (In the original opening-credits sequence, Rebecca herself called the term sexist—and, when the chorus cheerily sang “She’s so broken inside,” she insisted, defensively, that the situation was “a lot more nuanced than that.”) But “Crazy Ex-Girlfriend” wasn’t kidding about the crazy bit. When, in the last season, Rebecca got a definitive label from her psychiatrist, during a joyful, anxious number called “A Diagnosis,” it was the culmination of the show’s daring story arc, which had dwelled in darkness from the beginning. Rebecca, as that credits ditty recapped, was a miserable corporate lawyer who ditched her job on a whim, moving across the country to reunite with a sweet jock named Josh Chan, whom she’d dated, briefly, at summer camp. She took a job at a local firm, then proceeded to wheedle her way back into Josh’s life, charming and stalking, lying and manipulating, sure that he was her soul mate or, in the parlance of Internet fans, her one true pairing.

That was Season 1. It was behavior straight out of a romantic comedy but warped enough to hint at something more extreme. For three seasons, the show treated Rebecca’s boy-craziness, her outsized thirst and insecurity, the charismatic too-muchness that defined her—confidently, cunningly—as somewhere in between fabulous and horribly destructive, even as she believed that she was simply seeking her romantic destiny. Rebecca was the show’s heroine, but she was also the vehicle by which it interrogated (and satirized and embraced) a certain style of toxic femininity, seen through the lens of every pink-coded genre, including Rebecca’s drug of choice, musical theatre. Rebecca was warm and clever. She was loving and funny. The songs we heard were manifestations not just of her emotions but of her wit and passion. But she was also depressed, anxious, and empty—a self-centered drama queen (and drama-club queen) whose moods swung wildly, harming the people around her. In one first-season song, she called herself “the villain in my own story / the bad guy in my TV show,” hitting uneasily on what made a fairy-tale ending seem impossible. She was an antihero in a twirly skirt, certain that she was meant to be an ingénue.

In fact, at certain points, Rebecca might have been unbearable if we didn’t love her so much—and we did, through Rachel Bloom’s daring, openhearted performance, which made us see the character’s potential, not just her damage. The show’s signature song came at the climax of the first season, when Rebecca realized that Josh was on to her. Titled “You Stupid Bitch,” it was a wild and cathartic diva ballad of self-loathing: “You’re just a lying little bitch who ruins things / and wants the world to burn”—a lyric so relatable that it has doubled, for fans, as a perverse anthem of self-assertion, a way of putting the inside voice on the outside. (Me, I listen to it whenever I’m stuck on a first draft.)

Over three seasons, Rebecca rode the waves of three romances—with dopey Josh, sardonic Greg, élitist Nathaniel—until each crashed into a wall of dysfunction. She made mistakes that seemed unforgivable, including hurling violent threats and sleeping with her boyfriend’s friend and, in one particularly awful case, her ex’s father. By the Season 3 finale, the show was facing the crisis that was baked into its premise: if Rebecca never faced repercussions for her actions, the show itself would curdle, by seeming to glamorize unhappiness, making chaos “cute.” Airing on the CW, it had always been an idiosyncratic, offbeat production with a cult audience, perpetually at risk of cancellation. Now it had the opportunity to end things right.

Bloom and her co-creator, Aline Brosh McKenna, along with their songwriting partners, Jack Dolgen and the Fountains of Wayne genius Adam Schlesinger, stepped up. Rebecca went to prison, then got out; she went into therapy, this time for real. The final season reached for something that I’ve never seen a show pull off: dramatizing themes—among them repentance, sobriety, and humility—that are much harder to make more enjoyable than one girl’s madcap hunt for true love, let alone set to music. Rebecca made amends. She did public service. In the wake of her diagnosis of B.P.D., she began to “do the work,” as they say in recovery programs—step by step, workbook by workbook, resisting and then accepting medication, relapsing more than once. She quit her high-pressure job as a lawyer and opened a pretzel business that gave her better work-life balance. She struggled to make her relationships more mutual, to treat intimacy less like a drug, to let her friends be more than sidekicks. In essence, she struggled to be a more ordinary individual, to purge her inner Pippin, rather than continually crash into the sun.

At first, like Rebecca, the show struggled to pull this off. For a while, it jumped among the other characters in the ever-expanding ensemble—including Rebecca’s exes and her trio of close girlfriends, who had evolved from codependents, frenemies, and nemeses into peers—in a manner that sometimes jelled and other times fell flat. But a few episodes in, the season hit its stride, helped by the return of Greg, now played by a new actor, Skylar Astin. The recasting was pragmatic, a way of handling the fact that the original actor, Santino Fontana, left, in Season 2. Astin was another triple-threat musical star, but he lacked some of the acrid intensity, the self-loathing that matched so well Rebecca’s own. He was a kinder, gentler version of Greg, which altered the show’s chemistry.

The creators played it out beautifully, however, with a song that captured the show’s key theme: the hopeful idea that a person could, in fact, change herself, so much that she could become unrecognizably improved to the people who once knew her. Skylar Astin was Greg when he was sober; if he could do it, the show suggested, maybe Rebecca could, too. And, as Allie Pape pointed out for Vulture, “New Greg” ’s less abrasive quality also accidentally improved the show’s endgame by unstacking the deck, because he was no longer her obvious O.T.P.

And, in fact, the finale began by rejecting the one true pairing as its own blinkered delusion. In the very funny penultimate episode, Rebecca went on dates with all three of her exes, in a “Bachelor”-like competition that the entire ensemble placed bets on, as if they were “Crazy Ex-Girlfriend” fans. It was romantic, it was funny, it was musically satisfying: another perfect episode, using every character and even giving a minor role a full-on “Guys and Dolls” number. The finale, however, was quieter. In the very first scene, Rebecca took a peek into the future, at the disappointing truth: that she had the same look on her face, blankly depressed, no matter whom she chose. There was no right man, because the problem wasn’t love at all. It was her.