The Monday-night comedy concludes after nine seasons on March 31 with a one-hour episode.
The comedy's central conceit is that it's a story told by actor Josh Radnor's character, Ted, to his teenage children about how their mom and dad met. The children, played by David Henrie and Lyndsy Fonseca, were depicted in the series' early days sitting on a couch, shifting uncomfortably in boredom as their dad narrated the long-winded story.
Although the mother, played by actress Cristin Milioti, was introduced in last season's final episode, the details of how they met still haven't been revealed.
Series co-creators Carter Bays and Craig Thomas knew from the beginning exactly how that question would be answered, and always planned it for the show's final episode. And the kids on the couch would be a key component of that ending.
Yet in 2006, with the series in its second season and the possibility existing that it could be on for several more years, Bays and Thomas realized they'd better film that final scene right away. After all, the actors were growing up, would soon look different and wouldn't even be able to fit in the clothes they wear while sitting on the couch.
So one day Bays and Thomas brought the young actors in, closed the set to all but one camera operator, and filmed the two-minute scene that will bring the series to a close.
Through all the seasons that have come since, there hasn't been any reason to change it, he said.
"It's been the plan all along," he said. "What you see on March 31 has been the plan. We leave the series with a certain message that we wanted to convey."
Producers filmed some extra scenes with Henrie and Fonseca to give themselves some flexibility with writing the final episode, but the central idea is the same, said Pamela Fryman, the show's director and executive producer. The rest of the actors are scheduled to film the final episode on Feb. 28.
Milioti may not have had her job if the series hadn't lasted as long, however. Bays said producers had contingency plans for another mother—the baker character Victoria that Ted met during the show's first season—if CBS canceled the series. It was touch-and-go for the first few seasons until "How I Met Your Mother" built a consistent following.
"We really did have an eight-year plan," Bays said. "It turned out to be nine years."
In fact, the show has received criticism this year that its stretch marks are showing, that it is marking time until the finale. Some Asian-Americans reacted angrily to this Monday's episode, with actors dressed in Asian attire for silly scenes that the producers intended as an homage to kung fu movies.
Bays said the final season has been "a challenge," but the producers said they are proud they tried to push themselves creatively by essentially setting the ninth season in one weekend—the wedding weekend for Neil Patrick Harris' character Barney to Robin, played by Cobie Smulders.
The creators are now at work on a proposed spinoff, with a new set of characters telling a woman's story about how she met her children's father. The actors on "How I Met Your Mother" won't be involved, although Bays joked he may pay one of the current crew "a lot of money" to come in as a guest star in a third season when they run out of ideas.
Not all of the current cast members know how their show will end, although Harris said he cornered the producers at an office party recently and compelled them to tell the story.
"It's more complicated than you would assume," Harris said, "and for all of our fans, they won't be disappointed."