[This story contains spoilers from the series finale of HBO's Veep, titled "Veep."]

Veep's series finale was filled with heartbreaking endings, searing commentary and endless laughs during the Emmy-winning political comedy's aggressively fast-moving and time-jumping series finale. But amid the nonstop punches, it was the final joke of Sunday night's supersized goodbye that proved the ending of Veep to be a love letter to Veep itself.

Anna Chlumsky, who plays Amy Brookheimer, had said as much when discussing her reaction to how it all would end. "It’s a love letter," she said at the start of the seventh and final season. "I just looked and Dave and was like, 'Thank you.' And he said, 'We’re fans!'"

Now, after Sunday night's episode "Veep," written and directed by showrunner David Mandel, the sentiment behind that comment became clear.

After taking over from series creator Armando Iannucci after season four, Mandel has spoken about his unique perspective in transitioning from a dedicated viewer of Veep to running the show. That's why he and his writers — after no shortage of earlier season callbacks in the final episodes, most notably the Labor Day mystery hint — ended Veep with a callback to the pilot episode.

"I’ve said this since I took over — I was a fan of the show," Mandel tells The Hollywood Reporter about the fitting farewell for Selina Meyer (Julia Louis-Dreyfus). "I am truly a fan and I did the stuff as a fan that I wanted to see. Before this final season, I rewatched just about everything, especially the early episodes, and it was the opportunity to make that connection that I was very excited about."

In the very first episode of Veep, Selina Meyer and her team of incompetent staffers are scheming about how to fix the then-Veep's latest gaffe: Selina using the R-word. That's when her press secretary Mike McLintock (Matt Walsh) suggests they pause on her making a public apology and wait it out for a bigger news story to steal the news cycle. "What if Tom Hanks dies? I'm not wishing that. I'm saying anything could happen: Tom Hanks could die," McLintock says.

Flash-forward to the final scene of Veep and Tom Hanks does indeed die (at the age of 88 and after four Oscar wins, receiving a future statuette for "Philadelphia 2") and his death usurps the news about the late former President Meyer's death. After revealing that Selina does become president in the present-day ending — albeit, a totally alone POTUS after sacrificing everything and everyone — Veep jumped 24 years to her funeral to reveal the who's who of guests arriving to bid farewell to the one-term president who died at age 76 (or 77 or 75), outlasting only Ben Cafferty (Kevin Dunn), who presumably died from his umpteenth heart attack.

Mike is still a trusted anchor for CBS News, and just as her former press secretary is about to give the "underrated" politician a heartfelt broadcast TV eulogy, he quickly pivots to report on the breaking news of Hanks' death, shifting his poignant words to be about the actor's legacy. Hanks becomes the lead as the world "mourns the loss of an American icon" — one who isn't Selina.

"There’s nothing more Selina Meyer, even with her winning the presidency, than finally that the day she dies, somebody better dies and steals all her thunder," says Mandel of the full-circle callback and ending. "It’s the ultimate Selina Meyer: Utter, utter lack of respect, but in a form you’ve never seen before. (Laughs.)"

He continues, "There’s two really nice callouts to the pilot: when she starts to say the 'level of incompetence in this office' and then the Tom Hanks thing." The former mention is a reference to President Meyer's mutterings while alone in her Oval Office without any of her original staffers (except for returning secretary Sue Wilson, played by Sufe Bradshaw). "I told [Armando] at the season premiere [event] that she was going to win. I definitely didn’t tell him the Tom Hanks thing, but I told him there was a specific nod to the pilot and a cool callback that he would dig. I hope he likes it."

Before settling on the Hanks joke, other scene-stealing deaths were thrown around. The biggest one was that Selina's predecessor, the never-seen President Hughes, would have died on the same day and bumped her off the front page. "The notion of her funeral being bumped from the news I think would have worked with anybody. That was the joke as written and then [executive producer] Frank Rich reminded us of that joke from the pilot and we just thought, 'Oh, that’s perfect.' And, obviously, then it being Tom Hanks," says Mandel.

Once the Hanks bit was locked and loaded, the show had to get the actor's sign off on usage of the film footage used in the CBS News farewell montage, which included clips from Hanks classics like A League of Their Own, Forrest Gump and The Money Pit. And that approval process created a brief frenzy — not unlike the imagery of Selina's staffers running up and down the White House hallways — in the editing process.

"When we were in the sound mix we actually freaked out like, 'What if he doesn’t sign off on time?' or 'What if he doesn’t understand it?' And so Julia actually emailed [Tom Hanks] to say basically, 'Here’s what this joke is.' And we got back this an auto-response email that he was away and we thought, 'Oh my God, what do we do now?'" says Mandel, recalling how they scrambled and worried their request might fall through the cracks. "As we’re sort of running around with our hair on fire, a second email comes through and it’s from him and he was like, 'Absolutely. No problem.'"

Of his response once the episode aired, Mandel says Hanks emailed Louis-Dreyfus: "I think he dug it."

Before Selina's live funeral coverage gets bumped from Mike's nightly news report, viewers are treated to an update on how Selina's long sought-after legacy actually played out: The first female president served only one full term, is remembered for briefly freeing what was once known as the nation of Tibet and for permanently overturning same-sex marriage.

Still, the funeral she had planned out earlier in the season has Selina written all over it, as she is buried in her presidential library at Smith College (callouts to season six) with a slew of hand-selected dignitaries sitting in the front row. Former challenger and later two-term president Kemi Talbot (Toks Olagundoye) is tasked with giving the eulogy.

"Selina Meyer spent a lot of time worrying about trying to be president, but never spent enough time worrying about what she would actually do as president," sums up Mandel of how she'll be remembered in the world of Veep. "And by the way, that is sometimes a problem in politics."

Check back in for more from Mandel and keep up with all of THR's series finale Veep coverage here.