Here’s how the Silicon Valley season 6 finale ended the satirical HBO comedy. Silicon Valley was co-created by Mike Judge and his King Of The Hill colleagues John Altschuler and Dave Krinsky and is partly inspired by Judge’s own experiences working as a computer programmer in the NorCal tech hub during the late 1980s. The show follows programmer Richard Hendricks (Thomas Middleditch) – the founder of data compression start-up Pied Piper – and his fellow developer geeks as they try to make it big in the tech mecca.

Throughout its first five seasons the show hilariously sent up Silicon Valley culture as it chronicled the ups, downs and evolutions of Richard’s start-up – from socially inept coders and arrogant venture capitalists to all the backstabbing, job-hopping and corporate espionage that comes with them. By the time Silicon Valley’s sixth and final season rolled around, Richard and Pied Piper were on the up and up after pivoting to web decentralization, moving into a massive new office space and hiring hundreds of new employees.

Related: How Silicon Valley Season 4 Explained Erlich Bachman's Departure

It wasn’t all plain sailing for Richard and friends in Silicon Valley season 6, however. Pied Piper may have bought its biggest rival Hooli but the company was almost subject to a hostile takeover by a shady Chilean investor, lost out on a big deal with AT&T and nearly turned billionaire Russ Hanneman’s (Chris Diamantopoulos) vanity music festival into a disaster of Fyre Fest proportions. Luckily Richard saved RussFest last minute - with a little help from Martin Starr’s Bertram Gilfoyle and Kumail Nanjiani’s Dinesh Chugtai - which reignited AT&T’s interest, but their problems didn’t end there as the Silicon Valley season 6 finale proved.

Silicon Valley Thomas Middleditch

“Exit Event”, the last-ever episode of Silicon Valley, unfolded within the framing device of a documentary being filmed ten years later which reveals that Pied Piper’s victory was short-lived. In the present-day Pied Piper strikes a multi-billion-dollar deal with AT&T to host PiperNet, the company’s decentralized internet. However, Richard soon discovers PiperNet’s AI is so powerful that it can decrypt anything and has the potential to destroy internet privacy – meaning the security of everything from financial institutions to nuclear launch codes would be comprised. Basically, PiperNet is Skynet waiting to happen.

The Pied Piper team realize the only way to prevent their creation from bringing about doomsday is to destroy it and thus spend the bulk of the Silicon Valley season 6 finale trying to sabotage PiperNet’s launch so spectacularly it will seem like such a massive failure no one will try to copy it. Despite a few setbacks, they succeed in failing by uploading a faulty code which is designed to disrupt satellite signals but instead – in a brilliant play on the company’s name – sends out a frequency that causes rats to flood the streets of several cities across America.

Back to the future and the documentary reveals what became of the Pied Piper team – Richard is a professor at Stanford University where Big Head (Josh Brener) is president, frenemies Dinesh and Gilfoyle have set up a cybersecurity firm together, Monica (Amanda Crew) works for the NSA and Jared (Zach Woods) is working in a retirement home. Despite the seemingly happy ending, the Silicon Valley season 6 finale ends on a rather ominous note when Richard reveals that he still has a copy of the original Pied Piper code on a thumb drive somewhere – the only trouble is that he’s misplaced it.

Next: Halt And Catch Fire's Season 2 Soft Reboot Saved The Show