Credit: John P. Johnson/HBO (2)

[WARNING: This story contains plot details from Sunday’s season 4 finale of Silicon Valley, titled “Server Error.”]

At the end of Silicon Valley‘s fourth season, it came down to a rather familiar scene: Gavin Belson and Richard Hendricks meeting at a Mexican restaurant, with the former offering to buy out the latter’s start-up company, a mariachi band choosing an inopportune time to perform. But the song no longer remains the same on HBO’s beloved tech comedy after “Server Error.”

For starters, the game is getting bigger: Richard (Thomas Middleditch) is inching a bit closer to realizing his dream of building a decentralized internet, thanks in part to some code gifted by Gavin (Matt Ross) that he surely would love to take back now. And Richard bad-assedly breaks the news that the middle-out kings known as Pied Piper will devour the server-centric Hooli, not the other way around, as Gavin has vowed to do once again. Through the season finale, Richard continued to take a shortcut on the path to immortality by trampling through immorality, much like his enemy-turned-partner-turned-rival Gavin (Matt Ross) once did. He lied to his friends (Gilfoyle and Dinesh), berated them (Jared), took advantage of them (Big Head), and deceived consumers by sneaking unauthorized content on their phone before he finally came to his nice-guy senses and accepted responsibility for the mess that he and Pied Piper had made. (Which turned out to be not such a mess, thanks to some data-sharing, data-storing smart fridges. But also: R.I.P., Anton.)

And the winds of coming change also blew in from as far away as the Far East, where we saw Erlich for the last time. (T.J. Miller, as you know, is leaving the show.) How did the series bid farewell to the imperious impresario, the blowhard who tried for four seasons to moor himself to moguldom? Gavin — who would maneuver his way back into the good graces of the Hooli shareholders and displace the man who displaced him, Jack Barker (Stephen Tobolowsky) — first abandoned poor Erlich in an opium den in Tibet, because, well, if you’re going to leave Erlich hanging for eternity — or maybe five years — that seems as logical as any place to do such a thing.

What happens now to Pied Piper after Richard’s rejection of Gavin’s offer? What does life without Erlich look like? And will the smart refrigerator replace the smart phone as our primary means of communication within a few years? Let’s stop with the second-guessing, hand-wringing, pearl-clutching bulls— and call the man calling the shots, Silicon creator Mike Judge.

ENTERTAINMENT WEEKLY: Richard’s dream of a decentralized internet got one step closer to reality, thanks to some helpful smart refrigerators. Where the heck did you get that idea, and how pure is the science here? Also, should we be worried about a refrigerator uprising in 2032?
The science is pretty solid. We try to vet it through a lot of different people. A lot of times there’s an explanation that may take more explaining than we care to do in dialogue with the characters. For example, the tequila bottle in season 2 that was accidentally set on the delete button — that actually, through a perfect storm of mistakes, could happen, and we had that all explained in the dialogue at one point, and it was just too boring and we figured, “Well, when we get attacked on Twitter, we’ll just explain it there.” [Laughs] So there might be a little bit of that with this. But given that the compression algorithm is fictitious but supposedly somebody could [create this] — everything else is solid. And there are people working on this decentralized version of the internet, so that is something that is happening.

And we’ll be continuing that thread throughout next season?
Yeah. And the space-saver app that he’s doing is one step along the way. We looked at different ways that somebody could achieve this, and given limited funds, this would be a way to possibly build something to show that it could be done and then get funding.

The fortunes of Pied Piper rise and fall so fast. What is the biggest discussion that the writers have about balancing these reversals of fortunes? Is the looming danger always not to make it too Entourage-y, so you have to be Lucy and keep yanking that football away from them, to mix pop culture metaphors?
Yeah. In the beginning, if you had asked me at the end of season 1 where they’d be at the end of season 4, I would just assume that they’d be out of the house and be billionaires and all that [laughs], but we take it one season at a time. What we did with this big swing of the decentralized internet is that we realized we can’t keep having them fail and pivot. So the idea with this was that this is what they’ll be working on until the end of the series — at least that’s the way we’re thinking of it. And there are a lot of steps to building something like this.

The finale sets up a return to a central idea from the beginning of the show: Gavin versus Richard/Pied Piper. It was intriguing to see them working together, albeit briefly, this season. Were there discussions in the writers’ room to have them on the same team for a longer stretch? Gavin just seemed to have vanished early in the season.
From what I remember, initially, our plan was that he would be with them for a while. In season 3, we had this Skunkworks thing where they were going to be building their thing while they’re working under Jack Barker. We thought that would sustain several episodes of them building, and we spent weeks actually writing and outlining three episodes of it. Finally, we had to admit to ourselves that this just wasn’t working, and that’s when we got that idea to just have it all blow up in their face immediately — set it up like we were setting up the season and then they just s— their pants immediately. [Laughs] But [in this case], we just weren’t coming up with that much stuff to sustain it. And finally, we had these other ideas — working toward HooliCon — and also seeing Gavin fail and come back at the end of the season just seemed better. So we ended up going that route.

Well, it did, in its brief time, give us the Blood Boy. And Jared (Zach Woods) defending Richard to Bryce (Graham Rogers) — “You dick! You dick!” — was a highlight.
Yeah, I feel like Zach was on fire this year.

The show does a great job of filling in Jared’s dark past with these great little details — and other times, it just drops these disturbing hints that leave us hanging and saying, “Actually, I don’t want to know what Uncle Gerry’s Game is.”
That’s exactly the balance we’re trying to strike there. [Laughs] It just has this ring to it. It’s like, “Oh, god. I don’t know if I want to know what it means.” That was in the script but… a lot of this originally came from lines that Zach would just improv in the first two seasons. Almost none of them made it in, but they did influence our writing of the character. Then we just started putting them in in ways that made a little more sense, where it was a little more organic to the scene. He did one of my favorite improvs that he dropped in — we didn’t put in the show, but in season 1, they’re talking about who Gilfoyle’s [Martin Starr] girlfriend looks like, and they’re naming different celebrities, and Zach just [improvised], “She looks like my friend Gloria’s granddaughter.” It’s like, “Wow, that’s one sentence that says a lot about a guy. He hangs out with old ladies, and he’s met the granddaughter.” And then he started doing these things about his foster home. The idea that he was on the streets at some point, you don’t really want to know what he was doing, but it’s funny to know that he’s been that low down.

Speaking of the old ladies, we did get the joke this season about how he slept with the head of the assisted living facility to bump up his friend Muriel on the wait list.
Oh, right! There were a bunch of different options on that, and it’s one of the things where we shot a bunch of different takes, and I’m glad you like that one. That was the winner.

You’ve toyed with Richard breaking bad before in a previous season, but these last few episodes took him to new levels of dick-ery, especially with poor Jared. All of which is to say that this made Richard even more interesting. What’s the biggest challenge in writing the hungrier, more Machiavellian Richard?
It’s like eating your seed corn. I thought Thomas played it great. I liked watching him do something that’s out of character, it keeps you on edge, but if you do too much of it, it’s not Richard anymore. That’s why I thought it was satisfying to see him, after becoming a little unhinged, admit that he was just out of line. You don’t want to make him become so bad that it’s unlikable — and I suppose we could — but I think you’re ultimately going to want to see him redeem himself. I mean, who knows? We haven’t gotten to next season yet.

But for me, watching Thomas and Zach play those scenes was really great. I think the season finale may be my favorite episode of the series so far. I mean, the season finale of season 1 was right up there. Those guys were both playing some really subtle things — and then some not-so-subtle things. [Laughs] This was what I was always imagining the series would be, seeing a promise from the beginning: Is this character going to become corrupted by all this? And to see it come close to happening was where we’ve been headed from the beginning.

The cautionary tale of Gavin Belson.
That’s what we were sort of promising, so it was satisfying to do a little bit of that.

Jared finally stood up to his captain and (temporarily) quit the company in an emotional moment. Will we see him take more agency in his life next season?
I know among the fans, I hear it all the time, that this last season he really started to shine. It could very well be that season 5 is the season of Jared, you know? [Laughs] Like you were saying, you probably don’t want to know a whole lot more about his past, but we’re going to throw more to Jared this coming season.

Did you guys spend any time actually imagining the contents of his “Lordy, Lordy, Look Who’s 40” letter? Because I really want to read that.
Actually, when we were shooting, one of the writers started to write it, and we were in a rush, and I just thought, “Let’s not see it on camera — somebody will freeze-frame it and blow it up, and we haven’t got enough time [to write it].” But yeah, that would be a fun one to write. I know Dan O’Keefe wrote some really funny stuff on the profile page back in season 1. [Jared] had an a cappella group called Joyce Carol Notes. Those things are really fun to write.

NEXT PAGE: Judge breaks down Erlich’s final scene

We just got our last look at Erlich, and he was left behind at an opium den. Initially, you wrote that as a cliffhanger, but it wound up giving T.J. the idea of using that as his final farewell, right?
It was kind of clear that he was thinking that he didn’t want to do the show [anymore], so we were looking at it like, “[Let’s] make it so it’s an option either way. If he wanted to come back, he can.” Because that character is not a programmer, really — we had him program a little bit — and he’s not part of the company, a lot of times it’s hard to work that character into the stories. Sometimes we actually lean into it with him talking about this narrative that “I don’t have anything to do,” all that stuff that was in the seventh and eighth episode. So initially, I think we were talking about possibly having him go over to find Gavin. But not knowing whether he would come back or not, we wanted to leave that as an option, so that’s how that ended up.

Did you agree with T.J. that it was a fitting, perfect end to this character — and it showed how tragic this character was? You wrote it both ways. Did it take some time to wrap your head around the fact that this would indeed be his final act?
I guess I was in a little bit of denial and thought he’s maybe going to come back for two or three episodes or something. But once I actually saw him there, it is a little sad. [Laughs.] But we didn’t know for sure that that was the last one. If we absolutely knew for sure that that was his last scene, it would have been more sad. We knew it could be, but that’s a little different than knowing that it is.

In the second-to-last episode of the season when Erlich’s heading off to Tibet, no one can think of anything nice to say about him on his way out of the house. And then Jian Yang just throws his bag out of the car at the airport. And then Gavin just leaves him there in this opium daze. It’s a little brutal.
It is pretty brutal. [Laughs] But he and Jian Yang have always been pretty brutal to each other, it’s just the way the characters are. I love it, though. And I’m glad T.J. did because I think it is a pretty funny way to say goodbye to a character.

Sounds like you weren’t surprised that he wanted to move on. But how much of a loop did that throw you for when he decided to come back for zero episodes? How many episodes were you hoping he’d come back for?
We were thinking three, but we hadn’t started writing it yet. We were just going to try to maybe come up with something that happens in China. We just had a couple ideas, really. I wouldn’t say I was surprised. I thought it could go either way.

How big of a loss is it for the show to have to say goodbye to Erlich, who’s such a fan favorite?
Yeah, it’s definitely a loss. We haven’t started writing next season yet, but I’m glad we had him for the four seasons we had him. It’s been awesome working with him. We have a lot of other characters to throw to that have grown — I think Jared is definitely becoming a standout character. I’m hoping it breathes new life in it, and it reinvigorates. I actually talked to T.J. about this; he said the same thing. I mean, we’ve had them in the same dynamic and same house, and it forces us to come up with new dynamics and new ideas. We have some really great actors, great performers, great writers, I think we’ll make it work. If you look back, the show’s better with him, of course. Looking forward — it’ll force us to get more creative, and it could give us a second wind even, I would hope.

T.J. says that he thinks the show can benefit from this, and like you hinted about writing more for Zach, he sees it as an opportunity for actors like Jimmy O. Yang (Jian Yang) and Josh Brener (Big Head) and Amanda Crew (Monica) to get more screen time. But do you also envision that we’ll need a new oppositional force to bring inside Pied Piper? And if so, do you have any idea what that character looks like? Could it be a woman?
Yeah, it certainly could be a woman. I mean, we haven’t looked at just replacing him as a one-for-one. We always just put everything we got into the season we’re doing and worry about next season later, and we start writing next season Monday. We’ve had one or two conversations — I talked to Alec [Berg, Silicon executive producer] at dinner a week ago about it briefly, and already it was actually exciting in a way. We’ve had the same guy owning the house. There could be family members that inherited, there could be somebody that buys it. There are all kinds of ways to go with it, but it probably would be a good opportunity to get another female character into this — it’s been very dude-heavy. [Laughs.]

Does this mean that Pied Piper might move out of the house next season?
You know, we’ve thought about that since the beginning of the show. We haven’t started writing, but I guess if there was a time in the series to move out of the office, maybe this would be it, but also he can sell it from China for drugs. [Laughs.] That’s the kind of thing that could happen and we just haven’t figured that out yet. But if anyone has worries about us repeating ourselves, this will definitely shake things up, which I think could be a good thing.

Like you said, it can be hard to work Erlich into stories, and it seems like he was switching hats a lot, jockeying between pitchman, incubator, publicist, and venture capitalist. Was it getting even harder to find a way to fit him organically into the universe, or was that a challenge you enjoyed?
There’s all kinds of things about the writing process that are challenging, and that’s just one of them. The basic challenge of the show is that we’re doing a show about the work that these people do that is basically unfilmable; they’re just sitting there, programming, it’s all internal. It’s not like a medical drama where people are racing in. But because of that challenge, it makes this show more interesting. I guess it’s the same thing. That challenge was there almost from the moment that they get funded, but it actually led to a lot of funny things, so it’s not really a negative. I think it led to some fun things.

It led to a favorite moment that illustrates how he’s constantly and desperately trying to be part of the team that doesn’t want or need him: “Or do we?”, when he tries to interject himself into the situation and urges Richard to build the platform.
That’s one of my favorites. The thing that I’m going to miss. T.J. is always so good at being a little too loud. I did a little movie with him that came out in 2009 called Extract, and there was one line in ADR where I had him just pronounce the name of a band to a guy, “It’s pronounced God’s Cock!“ And he’s just saying this awful thing really loudly and it was just so funny to me. He’s just one of those guys who’s born funny.

The idea of Erlich being left in an opium den is something that T.J. loves — especially the part of the joke that you’ll never see him again in the show. Do you? Or will you ultimately try to coax him into returning for the series finale?
You know, it’s funny. When we locked picture on that and did the final mix on that episode, that’s the last time I’ve watched it through. At that point, I didn’t know whether T.J. was coming back or not, so I actually haven’t watched it knowing that that’s the last time. I think I like that idea. But it may affect me differently when I’m watching it now that I know that he’s not coming back. But the fact that he likes it, that kind of makes me like it too. I like his absurdist mentality. I think it’s funny. I was really happy with the episode. I would much more prefer that to some sappy, sentimental thing — at least for that character. We get a little emotional with some of these moments, but I think that was fitting for that character. I think. I mean, maybe I’ll change my mind when I see it again, with this new information. [Laughs.]

Gavin pays the man a bunch of cash so Erlich can have an opium hook-up for five years. How long do you think that he actually stays there?
In my head, he’s still there. I’ve never smoked opium myself, but I have taken Xanax, and I suppose if he really had given up, like he says when he leaves the house, he could be there for a very long time.

T.J. imagines that they yank the opium after five years, and he’s going to have the worst withdrawal you can imagine and try to figure out how the hell to get back to Silicon Valley. But he also threw out the idea that he was high on opium for only two years and then was operating in a Darknet situation with the Chinese government for the next three years.
[Laughs] He’s got a lot of ideas. We were talking about that Jian Yang said his uncle is very corrupt, and there could be something there that goes on with kind of a Silk Road thing. That’s what we were talking about when we were thinking about three episodes. Maybe that just happens off-screen. And in T.J.’s mind. [Laughs.]

T.J. said he’s loved working with you since Extract, and that you’ve talked about this not being the end of the relationship, whether you end up doing another movie or an animated show. Is that something you’re interested in pursuing? How serious is that?
Yeah, sure. Especially the animation part. T.J. is one of these people that’s just naturally funny. Someone like Bill Murray who just can stand there and stare at somebody, I think T.J. has that ability to just be funny — head-to-toe, he’s just born funny. It’s been great working with him. I’m a huge fan of Gorburger — and, you know Mucinex. [Laughs] All that stuff. Yeah. I love stuff he does, so I’d like to be included someday in something again — or the other way around.

You’ve been renewed for season 5. How many more seasons do you see in the show’s future? You’ve hinted in past interviews that we’re inching closer to the end.
Seems like six would be a good amount. I would hate to run it into the ground, so it feels like six, but if we get to the sixth season, and we have some idea or somehow it seems like it should be longer, and HBO wants to, I suppose it could go on as long as anybody wanted. But it’d be nice to not unnaturally push it to go longer than it feels like it ought to. But I think two more seasons — we have it in us. And for the story we’re telling about Richard and the company, it seems like that’s what it ought to be. But you never know.

What’s one hint that you can give us about season 5?
We’ll probably see the rise of Jared of some kind. I think it will be a Jared-heavy season. Laurie [Suzanne Cryer] was pregnant, so there’ll probably be a baby. There may be more than one baby.

Head here to read our interview with T.J. Miller about his exit and the season 4 finale.