Abby's type TV Show network NBC

In the first episode of Abby’s, Neil Flynn’s character, Fred, boasts that he’s been at the show’s titular bar every night for the past three years. “You’re the Cal Ripken of low-grade alcoholism,” cracks Abby (Natalie Morales). Whether it was accidental or not, the reference to Ripken — who played 2,632 consecutive Major League Baseball games — serves as a fitting tip of the hat to Flynn, the Iron Man of network comedy.

“I’m aware of it and grateful for it,” the 58-year-old actor says of his now 18 consecutive seasons on TV, before providing another baseball comparison. “Did you know that Jack Quinn had a longer career than Babe Ruth? Of course not. Just because he was around a long time doesn’t mean he was anything special,” he says with a laugh.

In 2001, Flynn was a self-proclaimed struggling actor, with a résumé full of one-off guest spots and movie roles like “Police Officer #1” and “Transit Cop.” Then he landed another of those: “Janitor” on NBC’s Scrubs. But the role turned into a memorable eight-year run — and the beginning of an even longer one. “I learned the ropes on Scrubs,” says Flynn. “I was lucky to be along for that ride; I came out of that with the confidence of knowing how a TV show runs and what’s expected of an actor.”

Before casting Flynn, Scrubs creator Bill Lawrence already knew how funny the actor could be. They were friends, and Flynn had even played the boyfriend of Lawrence’s wife, Christa Miller, in an episode of The Drew Carey Show (coincidentally, Miller was on TV continuously from 1995 to 2015). “There is nothing better than having a cast member so talented at being funny that it saves you time,” says Lawrence. “Occasionally we would literally write in the script ‘JANITOR: Hey, Neil, say something funny.’ ”

Image zoom Richard Cartwright/ABC via Getty Images; Michael Ansell/ABC via via Getty Images; Justin Lubin/NBC

When Scrubs was unexpectedly picked up by ABC for a ninth season in 2009, Flynn was already set to star on that network’s new comedy The Middle as Mike Heck, the patriarch of a lower middle-class family in Indiana. “There was a transition from Scrubs to The Middle,” he shares. “The characters were quite different. I was a down-to-earth man of few words on The Middle and the Janitor could do or say virtually anything and it would fit the character. I also learned quickly that the other actors on Scrubs had been committing a lot more of their lives to be on set than I had as the Janitor. With a bigger part comes many, many more hours at work. But I was 100 percent happy to be there; I welcomed the weightier part.”

The Middle ended last May after nine seasons and 215 episodes, meaning Flynn had completed 17 straight seasons and something north of 385 episodes of television. But instead of resting on his laurels (and network money), Flynn quickly signed up for another round, joining the cast of Abby’s. “I looked at the pedigrees of the producers and writers and was impressed by what they had done,” he says of creator Josh Malmuth (New Girl) and producer Michael Schur (The Good Place). “These guys have worked on some quality television, so I wanted to join up and see what we could do.”

With Abby’s future still to be determined, it’s possible that Flynn could be facing the end of the streak. But reflecting back, he believes that his years before success gave him the “perspective to appreciate and be grateful” for the position he’s now in, advice that he says he tried to pass on to the young actors who played his children on The Middle. “I’ve been at it for a long time, and it eventually paid off more than I could have expected,” he admits. “I guess I was eventually let into the party and just refused to leave.”

Abby’s airs Thursdays at 9:30 p.m. ET on NBC.

Related content: