Rebecca Bunch (Rachel Bloom) certainly went through the ringer in the third season of CW musical comedy “Crazy Ex-Girlfriend” — which ended on a note that not only saw her biggest breakthrough yet, but also one that will launch the show’s fourth and final season.

“We’ve been saying for a long time that we’re writing to the end — that it’s a four season show,” Bloom tells Variety. “We’ve kind of known that point from the moment we pitched the show what we want to say in the end, regardless of what actually happens specifically to Rebecca.”

The third season started with her plotting revenge on her ex Josh Chan (Vincent Rodriguez III), the man for whom she had moved across the country when the series started but who ended up leaving her at the altar in the second season finale.

“That first episode — or the first couple of episodes in general — there was a question of how heightened am I being? I’m someone who’s trying to pretend to be something, as if she’s a little kid playing dress up, and it’s supposed to kind of not fit — it’s supposed to be awkward. And that’s a hard thing to do tonally,” Bloom admits.

From there she dove down a dark rabbit hole that included a severe bout with depression and a suicide attempt before getting a new diagnosis of borderline personality disorder (BPD).

“This was always the season where Rebecca was going to spiral. We didn’t necessarily know about the suicide attempt from moment one, but the part of the season that surprised me was the uplifting moments,” Bloom says. “She spirals and then she gets diagnosed, and then the second half of the season becomes ‘How do you mix her mental health diagnosis with the things that the show was originally about, which is love and obsession?'”

Rebecca attempted a relationship with her boss Nathaniel (Scott Michael Foster) and got stalked by Trent (Paul Welsh), only to end up pushing Trent off a building because she feared he was going to harm Nathaniel.

The third season ended with her in a courtroom to face the consequences for those actions. Rather than leave the audience on the cliffhanger of how Rebecca would handle the situation, she admitted her wrongdoing and said she finally wanted to take responsibilities for her actions.

“That final monologue in the courtroom was one that was very easy to play because it’s a very logical walk-through of the show,” Bloom reveals. “It’s a monologue that’s thematically what we’ve been talking about in the show — the idea of someone who has no idea of who they are inside and lets external forces dictate what she’s going to do.”

What Bloom says was most important to her about getting to a point with Rebecca where her taking ownership of her actions feels genuine and earned was “cracking the guilt” she has carried over all of the things she has done that “were not only bad but also counter to her happiness — things that only made things worse.”

Bloom shares that in preparation for working on the fourth season, she is rewatching the first. And in doing so, she has been able to step back and acknowledge and appreciate how “really, truly messed up” Rebecca has been.

“Part of the reason she’s so f—ed up is because of this point we’re trying to make about love and obsession and happiness and well-being,” she says.

While Bloom adds that Rebecca’s personal journey is of course very important to chart all the way to the end — as is paying off “a lot of” callbacks and references from earlier seasons — ultimately what she says they are going for with their final season is “culminating the point” of the bigger theme of the show.

“The show has always been about the pursuit of happiness and how do you figure out what you really, really want in your life and not what other people expect you to want?” Bloom says. “So [it’s about] that pursuit of happiness — when is it healthy, when is it not and how to pursue [it] in a healthy way.”