It’s hard to follow 12 years on television as the same character, but that was what Matt LeBlanc had to think about after playing Joey Tribbiani, first on “Friends” for a decade and then on his “Joey” spin-off for another two. What character could stand a chance of being as iconic? Luckily, he didn’t end up having to look too far. In 2011, David Crane, who executive produced both of LeBlanc’s NBC shows, and his partner Jeffrey Klarik, wanted to do a show set in Hollywood around a problematic actor. And they wanted LeBlanc to play that character as a version of himself.

“I did have a reservation in the beginning. I wasn’t comfortable playing myself,” LeBlanc tells Variety. “But they said, ‘Well, we’re not making a documentary. If there’s anything you’re uncomfortable with, we’ll change it. We’ll get through it together.’ And it was because of my history with them that I really felt comfortable. I don’t know that I would have played that part with someone that I had a new relationship with. It was because of the trust that I said OK. I felt safe in their hands.”

Now, seven years and five seasons later, LeBlanc is saying good-bye to the fictionalized version of himself that he played on-screen on Showtime. Ahead of the series finale, LeBlanc talks with Variety about ending the show and how art imitated his life along the way.

What do you remember most intrigued you about working on “Episodes” years ago?

It was a very unique idea in how it made fun of Hollywood. There were shows that were about the business before, but this one really did it in an original way. There was a device in the show — the fact that Sean and Beverly were new to Hollywood, it allowed the show to explain Hollywood to them and therefore the viewer, so that it didn’t feel too “inside.” It could sort of lay things out, and it would feel like just any other industry. But yet it’s a crazy one. They made an industry that’s not relatable at all, really relatable. Because at the end of the day, it’s stories about these people, and that was what was intriguing.

What do you think you’ll miss most about “Episodes”?

When we’d get the scripts, the whole cast would be unable to put them down. We’d fire through them, it was great. They wrote the scripts in advance, so every year we’d get all of the scripts for each season and shoot it like a big film. We’d do a table read in the beginning of the production year of every episode, all at once. It was an all-day thing because it was nine episodes, and it was read one after another and another, and it was always fantastic. All of the actors, even the bit-part players, would sit down, do their thing, and it was just so much fun to do. The Showtime network execs would always fly over because we’d do it at the production office in London, and I remember David Nevins saying his sides hurt from laughing. “Episodes” will always hold a special place in my heart, regardless of any shows I do in the future, because of working again with David and Jeffrey and that connection to “Friends” in it and the trust factor. Those relationships, and their writing, that’s very special, and it was a lot of fun to do all these years.

David and Jeffrey told Variety why they wanted to end the show now, but did you agree, or could you have seen it going another two, three, four years?

We talked about it, but they felt they told their story. And there’s always the fear of jumping the shark. I definitely wouldn’t have entered into a situation where if they didn’t want to be a part of it anymore we’d do it with some other writers because then it wouldn’t be the same show. We always said we were in it together. The three of us — David, Jeffrey, and myself — always said anyone wanted out, that’s the way we’d handle it.

Having such a close working relationship with David and Jeffrey, how much input into how Matt’s story would be wrapped up did you have?

David and Jeffrey have got the story handled. They know exactly what they want to say and what stories they want to tell, and I don’t think I’m qualified to argue with them about what stories to tell. They’re so friggin’ capable!

Was it important to you to see him have a moment of growth before the end?

I don’t really know that he’s come that far. I think that he’s maybe a little more accepting of himself, but I think he probably always was. He’s sort of this island. And so am I, and so was Joey Tribbiani in that sense of he marches to the beat of his own drum.

But when his dad passes away, it does hit him harder than many may have expected, and you got to play more drama than for which the show usually allowed.

I don’t think he saw that moment coming, and I think that caught him by surprise, and I think what was nice about it was he really did love his father in that moment, and he feels the loss. I remember shooting all that stuff, and it was very, very tricky. I have a less-than-spectacular relationship with my own dad, so that was loosely based on that. I guess he’s grown in a sense, but I think it really catches him off-guard, and then after that he’s back to his old ways. I don’t think it changes him, but he cared more than he thought he did.

Alex Rocco was supposed to be in the season, but he passed away, so they decided to write it in, and I knew that was coming. What a great guy he was to work with! Just a sweetheart of a guy, it’s a shame. But it’s very typical of the way they write, that scene. They’ll take a very poignant moment, and they’ll build it up and build it up and build it up, and then they’ll undercut it with a joke at the end. So in retrospect if you look at it, it’s all a set-up for the punchline, but the set-up was so good you didn’t see the punchline coming. They’re brilliant at that, maybe the best. I can’t say enough good things about the way they write. I’ve just been so, so lucky to be a part of it.

Over the years, how much of that art imitating life aspect has come into the show?

The whole stalker thing. I did have a stalker in the hotel in London. There was a girl who was staying there while we were shooting, and she’d sit in the lobby every day from eight o’clock to six o’clock, but she didn’t realize I was leaving at like six and getting home at nine. So I had no idea, and the hotel security guys thought it was funny. I said they clearly couldn’t let that happen, but as a joke, I told David and Jeffrey that I went out with her, and they got so nervous. They got so upset that I kept it going for a few days before I told them I was kidding, and that’s how they got the idea that I’d have a stalker on the show. The part about her being a Make-A-Wish kid who never died was all them. They’ll take a seed of an idea, and it will grow.

How do you feel about how the show ends?

I thought it was a really nice twist at the end, what they’re writing and how my character ends up in it, too. He goes with his hat in his hand, so to speak, and he really has an ulterior motive, and they call him on it, and he doesn’t care. He’s shameless. What I like most about the end is that Sean, Beverly, and Matt are working together.

POPULAR ON VARIETY.COM: