Speaking to The Hollywood Reporter, Silicon Valley creator Mike Judge revealed that the finale as we saw it was slightly different from the original plans to end the HBO show. He said: “Yeah, we had a series ending in mind really since season two or three. It was not this one, but it had a similar thing to it in that it was Richard (Thomas Middleditch) basically sacrificing [his company.] But it was about him open sourcing it and giving his algorithm to the world as opposed to keeping it for himself and making tons of money.”

After Richard discovered that his AI was so powerful that it would teach itself to decrypt more and more elaborate encryptions, essentially meaning an end to privacy, the Pied Piper team have to deliberately destroy the company (or as Zach Woods’ Jared put it “shit ourselves to death”) which they do via a doctored version of the AI which they want to cause enough havoc to GPS and WiFi that no one wants to use Pied Piper tech any more.

However, it ends up sending out an ultrasonic frequency that draws out millions of rats to their launch like a…well…Pied Piper, in an event that becomes known as “Ratmeggedon.”

This was actually based on a real thing that happened to one of the show’s tech consultants. Judge told THR: “Todd Silverstein, one of our tech consultants, lived in an apartment and I guess the person underneath him was using one of these sonic devices to get rid of rodents, and all it was doing was driving them up into his apartment…It just seemed like this perfect thing that landed in our lap.”

As for what it was like to film with so many rats, he said, “It smelled like a pet store but with something else mixed in it that wasn’t good.”

Elsewhere, the show landed its biggest cameo ever in the form of Microsoft founder Bill Gates appearing as himself. Writer Alec Berg said of how they got the billionaire to appear to EW, “he’s a fan of the show…We usually, before every season, go to the Bay Area, but one year just to mix it up we went to Seattle, and he was nice enough to sit down with us for an hour and shoot the shit…He was a very supportive and nice and generous guy, and so when it came time to do this episode where it would be completely suitable to grab him for 10 minutes as himself, not as an actor, it just worked out.”

The series finale, however, did not see TJ Miller return as Erlich Bachman, though the episode did tease that he would return, before hinting that he had been murdered by Jian-Yiang (Jimmy O. Yang). Asked by EW whether they ever was a plan for the actor to return, he said, “no, there never was. But I like that people think he was going to pop up. That was kind of the design, to get people going, “Wait a minute, are we going to see him?”

Each of the character who did show up got their own endings; Laurie Bream (Suzanne Cryer) was seen in an orange jumpsuit in prison paying for an unspecified crime; Gavin Belson (Matt Ross) has written over 30 romance novels (sample titles: The Lighthouse Dancer, Fondly Margaux and, of course, Cold Ice Cream and Hot Kisses); Gilfoyle (Martin Starr) and Dinesh (Kumail Nanjiani) live next to each other and have a cybersecurity firm; Monica is working for the NSA; Jared is working with the elderly, while Richard is teaching at Stanford, with Big Head (Josh Brener) as his boss.

Speaking to TVLine about the decision not to reveal what Laurie may have done, Berg said, “that was a deliberate decision…The one conversation we had to have about what she [did] what she was wearing. In minimum security prisons people wear tan jumpsuits. And in medium and high security, they wear orange.”

As for how they decided about the other endings, he said: “We kept coming back to the question of, “What is success?” The whole show was [essentially] a rumination of, “Can you succeed on your own terms?”

“Ultimately, we decided for a guy like Richard success is not financial. Success is not commercial. Success is not being famous or powerful. He’s an artist [and] an engineer. And he did it. They built [a decentralized Internet]. But it turns out it’s so good it’s going to destroy human institutions. But that in and of itself is a form of success. [They] built something so good that the world can’t handle it.”

As for how Silicon Valley itself ended, we saw Richard try to show the documentary filmmakers the thumb drive containing the Pied Piper code base, only for him to be unable to find it. Berg said of this to EW: “I will be perfectly candid that we have no grand plan to return, but we were joking about it, like, ‘Oh, that’s the Silicon Valley movie, the search for the thumb drive.’ We just like the idea that they create this doomsday device and then, in the end, Richard forgot where he put it. It just seemed like a funny place to end.”

Silicon Valley is streaming now on HBO Go and HBO Now