SPOILER ALERT: Do not read if you have not yet watched “Zoey’s Extraordinary Dad,” the Season 1 finale of “Zoey’s Extraordinary Playlist.”

The time Zoey Clarke (Jane Levy) — and let’s face it, most of the audience of “Zoey’s Extraordinary Playlist” — has been dreading has come. In the first season finale of Austin Winsberg’s NBC dramedy, she had to say goodbye to her dad Mitch (Peter Gallagher).

Mitch, who is based on Winsberg’s real dad, had progressive supranuclear palsy (PSP) and over the course of the season declined further, from being unable to communicate verbally with his family to being unable to swallow liquids. Originally, Winsberg tells Variety, he planned to write Mitch’s death into the penultimate episode of the season and then use the finale to showcase some of the differences between how they grieved losing him while he was still alive and how they did so after he was gone. Instead, though, he moved that emotional passing into the penultimate act of the finale episode, using the final act to give just a glimpse at the posthumous pain.

Here, Winsberg talks with Variety about crafting the finale episode, including balancing some lighter moments in the front-half of the episode and seeing Zoey make strides in her love triangle, writing parallels to the pilot episode, pulling from his own family’s experience with death and the poetic nature of “American Pie” being the final song of the season.

In telling this fictional story, you have the freedom to do things differently than how they went for you and your family, if you wanted to. So what went into the decision to see him decline so quickly and ultimately not survive this first season?

What happened with my dad in real life, it was pretty sudden onset of diagnosis. When he was diagnosed with PSP, he died within nine months. And so, every week, it felt like we were losing another ability. Every week, we’re dealing with something new, something more to cope with and handle. And I felt like I just wanted to portray it in the way that it happened in our house. I felt like living in that space with it could potentially get repetitive or redundant, and I just wanted to be true to the stories and the experiences that I went through. I also feel like there is a lot after his passing — there’s a lot of story since my dad has died about our family trying to move on and what that looks like for all of us. So I felt like there was a lot more to mine after his passing and a lot more story to tell.

Was it a cathartic process for you to write this or did it just stir up painful memories with which you thought you had already dealt?

I was mourning my dad’s loss for about the last six months that he was alive and then for the six months after he died. My dad was a vibrant, dynamic, outgoing, athletic 67-year-old man when this happened to him, and then in less than a year he passed away from it. And so witnessing him getting all of those qualities taken away from him, I grieved before he died; I would go walk my dog every night and cry. And so it’s a weird process.

Peter does bear more than a passing resemblance to my dad, so there were absolutely moments on set where he would give a look or do a gesture or something that would be so exactly what my dad went through at the time. There were a couple of moments it literally surprised me; it took my breath away and I had to leave because I was too emotional.

What were some of those moments?

Certainly when they were doing the “True Colors” dance in the pilot, that was kind of wish fulfillment for me because I could [remember] seeing my dad in that almost catatonic state, but [here] he got up out of it. The very first time I saw that was very emotional for me. And in Episode 8, when [Zoey] sings to him and he’s kind of just very still and his eyes are closed, and then he turns to her and opens his eyes and his eyes are filled with tears. I didn’t know he was going to do that. And in the moment it made me gasp and I had to leave. And of course at the end. My dad was home for the end. And we don’t think the end was quite as peaceful for my father as maybe we tried to do it on the show, but certainly some of those moments where he’s gasping for air and breathing and the family is all around him telling him how much they love him, that was just straight from our own life and that was that was hard for me.

How did you work out the balance of the finale so that there would still be pivotal moments where Zoey had to deal with her feelings for both Max (Skylar Astin) and Simon (John Clarence Stewart) amid everything else going on?

When first talking about what the last episode was going to look like, I was going to have the entire episode take place over the course of several hours while he was passing away. The last day that my dad was alive we learned at around 4-o’clock that he was going to die that day, and then various friends and family members came over to say goodbye. And I was going to do a whole episode like that. And when we started breaking all of that down, it felt very sad. And it also didn’t really feel like it was in the tone of the show; it felt like it was important in the first three acts of the episode to be in the lighter tone, to deal with the love triangle and the work stuff, and then once the news hits to go to that sadder place. I felt like if we were in that sadder place for the whole episode, it would have been too much.

There were still some unanswered questions about the left triangle stuff. I felt like without being declarative, one way or the other, I wanted to create some real romantic movement with her. Because she had gotten more intimate with Simon in Episode 10, it felt like Max deserved his moment, too. And I wanted to end the season feeling like there’s a degree of potential optimism for Max and Zoey to take things to the next level — but also to remember that Simon is still there; he’s not there going anywhere either to keep the balance alive and the love triangle going. We also decided by the end that we wanted to show that Simon and Max are both worthy suitors and the both of them are good guys. It was important to me to not completely villainize one of them or make it so clearly black and white [who she should choose].

There is also that moment that calls back to the pilot with Zoey and the MRI. Is that to intentionally tip off that maybe her powers are caused by something physical going on with her?

My thought process behind that for the finale was that there’s still a bit of a mythology about what happened to her — and why. And I think that’s something that we can continue to explore in series. So I wanted to keep mythology of the powers alive, and I just wanted to remind the audience of that. I like it in shows where there’s a mythology that is lightly woven throughout, and I thought that was kind of an elegant way to keep it alive and to know that we’ll still be touching on that going forward.

But there’s a bunch of stuff in the episode that parallels the pilot. In the scene with her father, where she goes to talk to him, she gives basically the exact same speech she gave him on the couch when he sang “True Colors,” only in that speech she was talking about everything bad that was going on in her life — this new power that she’s not sure about, the guy at work she has a crush on but who has a fiancee — and in the last episode, she chooses to talk to him about the positives — how she thinks the powers might be a good thing and how the guy she has a crush on actually likes her too. I think by her telling him that she’s OK, she’s also giving him permission to move on. And that was very intentional to keep joy and hope alive in the show.

As the family is preparing to say goodbye to Mitch they all have musical moments of closure, but Zoey’s dance with her dad is different.

We had seen him sing to her all season, and after going through a lot of songs, what I realized was actually more powerful was to give them a conversation. They’re in silence and you can’t hear the song anymore, but he does tell her in those moments some of the words she needs to hear. And, his goal in that moment is to take her away from witnessing the end.

As in, his soul leaving his body before his body physically shut down?

I think that’s a good interpretation. I think it’s not wanting her to see the end. I think it’s a version of him moving on — of him not in that body anymore at the end. For me, watching my dad in those last few moments was so painful. And I think in that moment, Mitch is trying to protect Zoey. So Mitch is trying to get her to not be there to witness what the very end looks like in the ugliness of that. Instead, he calls her out into this other room to give her his own kind of goodbye. So I think that was him, his last way of reaching out to her through song — or through whatever this magical thing is that happens between the two of them — where he’s saying, “Don’t look back there. It doesn’t matter what’s going on in there. What matters is you and me right now.” And they’re able to have that final dance together, they’re able to talk through some things together, and then when she looks back in the room one last time, then he’s gone.

What inspired you to follow that up with one more musical number?

I didn’t want to see the actual funeral; that was important to me. After we kind of deal with the heaviness of the final goodbye, I felt like the next thing to do is to show the support that the family has and the love that is around them and the characters that will stay in their lives after this has happened. It felt a bit like at the end of the musical where you bring everybody on stage and they all get some moments. I liked everybody coming together in the house. It starts in daytime and it ends at night when it’s just the four [family members] left alone with, “Now how do we move on, and now what?” And also, there’s this empty spot on the couch where Dad used to be — where dad was most of the season.

How did you settle on “American Pie” for that song selection?

All season long, Adam Davidson, who was a producing director, and I talked ways to expand the language and the vocabulary and the conceit of the show, and when we hear songs and what they feel like. Adam said we could do an entire act that’s all one song, and we just started talking about what songs are long enough that lend themselves to the feeling of that. And other than “Hotel California,” “American Pie” was the song that came up — and “American Pie” happened to be, to my memory, my dad’s favorite song. Zoey singing by herself does kind of break the rule a little bit — we call it “zoe-ality” when she goes into her head and she sees somebody else’s musical number — but for Zoey in the moment, it’s the day the music died because so much of that music came from her dynamic with her father.

The literal last moments of the episode when Zoey is singing are very raw and grounded, unlike the “zoe-ality” moments of the show. Did you intend that to mean she is singing aloud and her family can hear her?

I don’t think it’s supposed to necessarily be a literal “She’s singing and the family’s hearing this” situation. I think it’s all the external expression of the internal emotion that they’re all going through.

The series has not officially been renewed yet, but if and when it does, do you anticipate picking the story up in the immediate aftermath of this loss?

I think it’s probably good to have a little bit of time passed between the seasons — because I think that the immediate grieving is very strong and I think that we need to have a little bit of distance there so that we can start to see what things could look like in the next chapter.