While shooting the pilot for “How I Met Your Mother” back in 2005, Alyson Hannigan genuinely believed the show was destined to fail — not because everything was going wrong, but because everything was working out just right.
“It was so wonderful,” recalls the actress, who plays Lily. “Everybody got along so well, and it was such a great experience. It was just too perfect. You were like, well, ‘That’s doomsville.’ ”
In this case, good vibes weren’t bad omens. The show about Ted Mosby’s (Josh Radnor) rocky journey to find the woman of his dreams became a CBS mainstay, delighting its passionate fans with nine full seasons of barroom laughs, musical numbers, Bro Code shenanigans, silly catchphrases, romantic angst and “legendary” slap bets.
When “How I Met Your Mother” airs its hourlong series finale Monday, it will depart as prime time’s third-most popular comedy, behind heavyweights “The Big Bang Theory” and “Modern Family.”
“It’s just the best gift ever that it stuck around for so long,” says Jason Segal, who plays Marshall, Lily’s husband. “We lucked out.”
Luck may have been a factor, but the longevity of “HIMYM” also was a product of smart writing that managed to deftly blend whimsical hilarity with emotional depth. And then there was its sparkling five-headed cast — including Neil Patrick Harris and Cobie Smulders — that, from the start, oozed youthful energy and quirky chemistry.
The show had another key strength going for it: a streak of creative defiance. Over its run, starting with its offbeat “who’s the mother?” framing device, creators and executive producers Carter Bays and Craig Thomas refused to be slaves to sitcom convention.
They shot their show on a soundstage, but without a studio audience. They made liberal use of flashbacks, flash-forwards and lightning-fast scenes. They had their characters break into song. They delved into weighty issues that other comedies wouldn’t touch, including the death of Marshall’s father.
And for this, their ninth and final season, they revamped the entire narrative structure by lathering all 24 episodes over a single weekend leading up to the wedding of reformed playboy Barney Stinson (Harris) and former commitment-phobe Robin Scherbatsky (Smulders). In the process, they, at last, brought the titular “Mother” (Cristin Milioti) into the story with a touching episode told entirely from her point of view.
“There have been pitfalls in the structure,” says Bays, during a round of interviews conducted amid the cozy MacLaren’s bar set on Fox’s Stage 22. “But you give yourself challenges. That’s why you get up in the morning.”
Radnor, for one, was always confident that Bays and Thomas could pull it off.
“They are geniuses at scrambling narrative and playing with time,” he says. “So I knew that they were going to find endlessly inventive ways to do that. And not only that, it sounded like a lot of fun.”
Fun and perhaps a little risky. But Bays and Thomas — old college chums — have always approached “HIMYM” with an aggressive, go-for-broke spirit. How many producers, after all, would peg the premise of their sitcom to a mystery? And how many would then have a “Lost”-like audacity to tease out that mystery until the final episode of the eighth season (and even then, providing only a brief glimpse of Ted’s future wife)?
With its long-running mythology — and all those red herrings — “HIMYM” kept its fans guessing. Of course, not everyone was always pleased. Some viewers simply craved a quicker resolution.
“Around Season 4 people started to think our show was a big puzzle, like a game they were supposed to solve. … But the show was never intended to be something to solve,” Harris recalls.
Adds Thomas, “It was our hope that this would become a show about the audience wanting to spend time with the cast and hearing a life story be told. … Of course there were voices that were impatient along the way. But we always felt like we had the right timing up our sleeve. We always hoped we would have a long run, and we always knew how we wanted to end it.”
Naturally, all involved are mum about that ending, which was shot in late February. Bays and Thomas, who liken themselves to evasive politicians, have even refused to address recent fan speculation that a future Ted might be a widower.
All they’ll say is that the finale, titled “Last Forever,” is an “ambitious” hour that covers 17 years in the lives of all the characters, and that “big, important things will happen.” Oh, and viewers will finally learn the mother’s name.
Spoilers be damned, Smulders is just grateful that the show managed to charge its way to the finish line with plenty of comedic fuel left in the tank, and that Bays and Thomas were able to wrap things up on their own terms.
“They plotted this out for nine years,” she says. “Literally, this is how they intended to end the show nine years ago, which I think is something that never happens. You usually listen to the critics or the fans, and they want this to happen or that to happen, and you get swayed, or you change your mind. But they really stuck to their guns, and I think the result is going to be amazing.”