Goodbye, friend.

The end of the road for USA Network's critical hit Mr. Robot is in sight, as the previously announced fourth season of the Sam Esmail-created drama starring Rami Malek will be its last. The network-defining series will begin production in the winter in New York for a premiere in 2019, meaning the show will have been off the air for more than a year when the final season debuts.

Season four, announced in December, was originally set to feature another cycle of eight episodes (its lowest order to date), but sources say that order has now been expanded to 12 (which mirrors its sophomore run). Sources say producers including Esmail toyed with the idea of plotting out a fifth season.

The fourth season writing schedule was split in two in order to accommodate Esmail's work on Amazon's Julia Roberts drama Homecoming, which like Mr. Robot is produced by Universal Cable Productions. The Mr. Robot writers room was moved to New York, where they were poised to finish season four and break all of a potential fifth season. Ultimately, those close to the show decided to increase the order for what is now the fourth and final season of the hacker drama.

"When I first created the world of Mr. Robot, I thought it would be a niche television series with a small, cult following. Over the past three years, it has become so much more, and I am continually humbled by the show’s recognition and by the amazing cast and crew that work tirelessly to help bring my vision to life," Esmail said Wednesday in a statement to The Hollywood Reporter. "Since day one, I’ve been building toward one conclusion — and in breaking the next season of Mr. Robot, I have decided that conclusion is finally here. Everyone on the creative team, including the amazing people at USA and UCP, didn't want to say goodbye, but we ultimately have too much respect for Elliot's journey to extend past its inevitable ending. Therefore, season four will serve as the final chapter of the Mr. Robot story. To fans of the show: thank you for the past three years, and I can't wait to share this exciting final season with you."

The decision to wrap Mr. Robot with season four should come as little surprise given Esmail has never had a long-term vision for the series. "I've always said it's four or five seasons, and I've said that because I think it's somewhere in between," he told THR after the season three finale in December. "Whether that means the next two seasons are two short seasons, or it could technically still be two full 10-episode seasons, we're still kind of figuring that out. It's something the writers room and I take very seriously. We never want to feel like we're treading water. Hopefully it fits into two more seasons, but we're trying to figure out that number."

Never a ratings breakout — the season three finale wrapped with a series-low 450,000 same-day viewers (growing to 857,000 viewers with three days of DVR) — Mr. Robot helped USA Network rebrand from its former "Blue Skies" brand of uplifting procedurals to a darker and edgier fare (along the lines of current hits The Sinner, Queen of the South and its upcoming Bourne spinoff Treadstone) in a bid to court millennials. The series took off as a critical sensation in season one, scoring an early second-season renewal on the day of its premiere and a lucrative overall deal for Esmail with UCP. Esmail opted to direct every episode of season two as critics suggested his tight grasp on the series was partially to blame for the show's sophomore slump. Still, the series earned a Peabody Award and netted star Malek an Emmy win for lead actor in a drama as the series also scored a nomination for best drama.

"From the beginning, Mr. Robot proved to be a show unlike any other on television, capturing the zeitgeist of our modern times with a unique point of view and definitive vision,” USA Network president Chris McCumber said. "Working with Sam and the entire cast and crew has been nothing short of incredible — and we can’t wait to reveal the complete Mr. Robot story."

Esmail, meanwhile, next has Amazon's Homecoming and the USA Network drama pilot Briarpatch, starring Rosario Dawson, in the works. Esmail — with his wife, actress Emmy Rossum — is also set to adapt The Hollywood Reporter's Angelyne feature story and is readying a miniseries based on Fritz Lang's sci-fi classic Metropolis, all via his Universal Cable Productions deal.

"The story of Mr. Robot is completely original and exhilarating — striking a cultural chord at just the right time. As we begin production on the final chapter of this iconic series, we want to thank Sam for his unparalleled vision, the masterful crew and the passionate cast who breathe life into these rich characters. We’d also like to thank our partners at USA Network for embracing this revolutionary series," UCP co-presidents Dawn Olmstead and George Cheeks said in a joint statement.

For his part, Malek has parlayed his Mr. Robot role to big-screen gigs, including his leading role as Freddie Mercury in the Queen biopic Bohemian Rhapsody. The actor will return for the final season, which picks up where the season three finale left off and will explore the pros and cons of Elliot sending an email that could reverse 5/9. Christian Slater, Portia Doubleday, Carly Chaikin, Martin Walstrom, Grace Gummer, Michael Cristofer and BD Wong co-star on the drama, which hails from Anonymous Content. The latter's Steve Golin and Chad Hamilton executive produce alongside Esmail.

The decision to wrap up Mr. Robot arrives as USA Network recently canceled the dramas Colony and Shooter — both after three-season runs — and picked up Treadstone to series. USA's slate currently includes the lone "Blue Skies" holdover, Suits, and its upcoming spinoff Queen of the South, The Sinner, The Purge and the anthology Unsolved, the latter of which is awaiting word on season two. On the pilot side, the cabler has Erase, Dare Me and Esmail's Briarpatch.

For management and production company Anonymous Content — which reps Esmail — the company also exec produces Homecoming and next has Netflix's Maniac, Hulu's Catch-22, Patty Jenkins' TNT drama I Am the Night and more.