LOS ANGELES — It took nine years, but the — wait for it — legendary tale of ABC’s “How I Met Your Mother” comes to an end Monday when the comedy takes a final bow.

Fans of the show have known since the end of last season who Ted (Josh Radnor) would finally settle down with, but it all becomes official with the one-hour finale.

The wild antics of five close friends — played by Radnor, Jason Segel, Cobie Smulders, Neil Patrick Harris and Alyson Hannigan — that’s been wrapped inside the long narration of the story provided by Bob Saget has been one of the big comedy hits for CBS with more episodes than network classics such as “The Mary Tyler Moore Show,” “Rhoda” or “The Dick Van Dyke Show.”

The end of the show will be a big change for Hannigan, who has played Lily in the 208 episodes. She came to the comedy after a seven-year run of 144 episodes on “Buffy the Vampire Slayer,” which means she’s had a steady job for almost two decades. After two long-running hits, Hannigan has a little concern for about what will come next.

“Because ‘Buffy’ was my first successful show, I think creatively it will always me by first love. That’s why I was afraid I would not find another great series after ‘Buffy’ ended,” Hannigan says during an interview on the set of “How I Met Your Mother.” “But, I was so blessed that I found this. Now, I’m hoping for a hat trick with a third series.”

One of the reasons she’ll miss “How I Met your Mother” is that each episode was a surprise. During its run, the actors have seen their characters bounce through different time periods, break into song, be part of weird fantasies and tell stories from a variety of perspectives. It rarely adhered to the basic rules of a traditional half-hour TV comedy.

Because of that off-beat perspective, Hannigan describes the scripts for the series as getting a gift every week.

Although CBS stuck with the series from the start, Hannigan wasn’t certain until season three that there were any fans of the show. Because the series doesn’t shoot in front of a studio audience, there was no immediate feedback each week. It wasn’t until the cast made an appearance in San Diego for Comic-Con — and she saw people waiting in line for hours for their panel — that Hannigan finally appreciated how much the show was liked.

Hannigan hopes her next project is a comedy that’s shot in front of an audience. That way she’ll get immediate feedback.

Segel came to the show after being on two highly touted series — “Freaks and Geeks” and “Undeclared” — that didn’t last a full season. That made him a little cautious about the future of the show.

“I was always ready for the show to be canceled,” Segel says. “And then, the fact that we got along so well made it almost a sure thing to be canceled. It’s just the best gift ever that it stuck around for so long. We lucked out. It’s been like a dream experience.”

Harris — who played the woman-crazy Barney Stinson until the character’s wedding to Robin Scherbatsky (Smulders) this year — wasn’t certain the show was a hit until the fourth season. That’s when it became available in reruns through syndication.

“The first two seasons seemed very on the bubble the entire time, which actually I thought was good for us and for the show. It gave us the opportunity to come up with our own sense of humor, and sometimes when a show is thrust into success right away, then there’s high expectations for them to come up with terrific stuff superfast,” Harris says. “We got to develop a great vocabulary and weird little inside jokes so that by the time fans — Netflix-style and syndication-style — started watching it, it had found its own voice.”

No cast member has been as connected to the show’s specific vocabulary more than Harris. Barney became a walking catch phrase, from “legendary” to “suit up.”

Radnor knew there was something special in the writing that gave the series an edge over other TV comedies. As soon as he started reading Ted’s lines, what he was saying felt real. And that never changed for him during all nine seasons.

The only major cast change for the show came at the end of the eighth season when Cristin Milioti, who plays the mother that everyone has been waiting for Ted to meet, was cast. The producers had seen her on stage in “Once” and on an episode of “30 Rock.” That was enough to bring her to Hollywood to test with Radnor.

She was a little nervous about joining the show because the core group had been together so long. She had little time to think about joining the show because she ended a two-year run in “Once” and 24 hours later was filming the eighth season finale where fans finally saw her character.

As for how the cast looks at the show, Smulders sums it up best: “This is a good gig. This is a great gig.”

©2014 The Fresno Bee (Fresno, Calif.)

Distributed by MCT Information Services