Twenty years ago, Star Trek: The Next Generation writers Ronald D. Moore and Brannon Braga faced the TV writer's equivalent of the Kobayashi Maru (that's a no-win scenario, for you non-Trekkers out there): Not only were they tasked with scripting the first TNG movie, 1994's Star Trek: Generations, but they also had to craft a two-hour series finale that would put a bow on Star Trek: TNG's seven-season TV run. And oh yeah, write both scripts at the same time.

The result: "All Good Things…," the immensely satisfying and beloved TNG finale that aired May 23, 1994 — 20 years ago this week. When Yahoo TV reached out to Moore and Braga to speak about the finale, they both seemed surprised to learn it's been 20 years since it first aired. And shockingly, neither has actually watched the episode in the two decades since. ("Maybe I will for the Blu-ray or something," Moore laughed.)

But both graciously spoke to us at length about their memories of writing and filming the landmark episode, including how they landed the coveted assignment, the comedic subplot that didn't make it into the final script, and why they think "All Good Things…" turned out so much better than Star Trek: Generations did.

"I don't know how or why, but I'm moving back and forth through time."

Moore and Braga had been working on the Generations film script for a full year when it came time to write the TNG series finale. And they weren't expecting to get the call.

Moore: "It was actually kind of a surprise. There was an assumption for the whole writing staff that [executive producer] Michael Piller was going to write the finale. He was the showrunner, so we kind of assumed he would reserve that for himself. But he was busy with Deep Space [Nine], and at one point, he just said, 'No, Ron and Brannon, I want you guys to write it.' We were surprised, and honored."

Braga: "I don't even know why we were necessarily asked to write the finale, given that we were writing the movie at the same time. All I can say is we were much younger. It's hard to imagine doing that again. But we were very much into it, and we loved the show, and ironically, the finale turned out better than the movie, so… but it was hard to do. We were both working around the clock."

Once they got the assignment, Moore and Braga huddled with the TNG writing staff to hammer out a concept for the finale. The plot: Captain Jean-Luc Picard (Patrick Stewart) finds himself jumping back and forth between three timelines — past, present, and future — all at the behest of Q (John de Lancie), the omnipotent troublemaker who put humanity on trial in the TNG pilot "Encounter at Farpoint"… and isn't done toying with Picard yet.

Moore: "It was kind of late in the game; we really didn't have a lot of time to figure it out. There had been various ad hoc discussions over the [previous] year or two about what a series finale could be, among the staff. Nothing really formal. And some of the ideas that coalesced that we knew we wanted to do were, just do a Q show. There was a general thought of, we should go back and do something with Q for the finale. It would kind of bookend the entire series."

"And then we started talking about time, because we wanted to revisit the events of 'Encounter at Farpoint.' So there was already an idea that we wanted to do something that would play around with time, because you wanted to go back to the beginning. And I think it was Michael [Piller] who said the show should be something about the phases of a man's life."

Braga: "I think that I, being the resident time-travel dude, I had the time-travel hook and Ron had the hook of bringing Q back into the picture and coming full-circle to the pilot where we're put on trial again. And it was a perfect combination. The time travel allowed us to show what the characters were like when the show first started. And even an android like Data was different! Writing the characters in each timeline was a little bit different, and it was just a really exquisite device to kind of do a Christmas Carol-type episode with a sci-fi twist."

Moore: "There was something in that title, 'all good things must come to an end,' that was really us talking about our own experience on the show. It was really self-reflective more than it was for the characters, because the characters were going to go on, but our relationship with the show was about to end. And I think that sense of smelling the roses and appreciating where you are was definitely a place that we were as we were writing it. Because it was like, 'Wow, this is all going to stop. And yeah, the features will be great, and they'll do a bunch of those, but it'll never be like this again.'"

Braga: "It's some sort of miracle that we were able to make the episode seem like it was about something. [Laughs.] We were writing it, not even fully knowing how we were going to quite end it."

Beyond the inherent challenges of wrapping up the Enterprise-D's TV mission, Moore and Braga also had to leave the characters' story arcs open-ended, since they'd be moving on to star in a number of Star Trek feature films.

Moore: "We revisited the Worf/Troi/Riker triangle [in the finale], which we kind of played around with in that final season. But we didn't really give it resolution, or platform it into the movies. Part of that was, there was sort of a schizophrenic attitude towards that whole idea on the show. Next Gen was slowly moving in its last season or two to do a little bit more with serialized storytelling, to sort of play out longer story arcs with some of the characters. But there was a lot of resistance from Paramount about it; [executive producer] Rick Berman was not sold on it. It was something that we writers wanted to do, but we were sort of howling into the wind, to an extent. So we didn't really concentrate on bringing any of those storylines to a conclusion."

Braga: "I'm pretty sure that if we hadn't been writing a movie, we still would've written the same script for 'All Good Things….' Because it was something we'd been noodling with for a while. And I think the story we told was unique and kind of perfect: the past and future kind of thing. So would we have done something more daring: killed a character, or done something wacky? I don't think so. I think we would've gone after the very same kind of bittersweet ending that we had."

"It appears we will be required to ignite the midnight petroleum, sir."

Once the concept was settled on, Moore and Braga went off to write the story outline and the script for "All Good Things…" together.

Braga: "My memory of writing it is just writing, nonstop. All I can tell you is, I was in my 20s."

Moore: "One person would be at the computer — generally Brannon, but I would take turns doing it, too — and the other one would pace or sit and talk, and the guy at the computer would be in charge on getting stuff down as he and I talked through what the scene was. We would talk through the dialogue, we're imitating characters' voices, we're acting out the scenes… that was the way we had always worked, and we continued to do that right to the end."

Braga: "We would work either at the office or at Ron's house in Burbank. Yeah, one of us would type and one of us would pace and talk. It's funny; when I think back on it, I don't have stressful memories. I have only memories of feeling really good about what we were doing. I thought we were doing a really good script, but I never could've predicted it would be such a beloved episode of television, certainly among Star Trek fans. That, I didn't realize."

An early version of the outline for "All Good Things…" brought back another one of the great Star Trek villains: the monolithic cyborg collective known as the Borg.

Moore: "The first story outline, I think, had four timelines that we were going to go back to. The fourth one, which eventually got dropped from the final teleplay, was revisiting the events of [the classic TNG episode] 'The Best of Both Worlds,' when Picard was taken and turned into [a Borg named] Locutus. So originally, the finale was going to bounce between those four events. And Michael [Piller], I think, rightly said, 'It's one too many, and we want this to kind of be the beginning, middle, and end of his life.' And that kind of simplified everything, and it became much cleaner and easier to go through it from that angle."

Braga: "We talked a lot about the Borg, and wanted to find a way to get the Borg back into the show, but we could never find anything that would top 'Best of Both Worlds,' other than those standalone Borg stories: Data and the Borg; 'I, Borg.' It felt a little superfluous to put it into 'All Good Things….' Three timelines felt like the right amount of timelines. We would, of course, end up using the Borg for one of the movies later [1996's Star Trek: First Contact], and they were much better on the big screen."

Moore and Braga's "All Good Things…" script includes plenty of in-jokes for Trek fans — including the future Picard barking his usual beverage order, "Tea, Earl Grey, hot," at a Cambridge housemaid, who replies with "'Course it's hot!" But there were even more that didn't make the final draft.

Moore: "There was a sequence that was cut at some point in the process that I wish we had. The idea was that the Enterprise-D was actually a museum ship and [Picard and company] had to go steal it, which was somewhat of an homage to [the 1984 film] Star Trek III, where they stole the old Enterprise. But it was also an opportunity to go on a guided tour, where they were gonna infiltrate and become part of the guided tour, taking them around to all their old stations. They'd be standing on the bridge while some docent was saying, 'Over here would stand Commander La Farg,' mangling his name. It was gonna be a really fun little thing that sort of had them looking back at their own life and history through the eyes of the future."

Braga: "There was really no room for that kind of zaniness."

Moore: "I think we just wrote the crap out of it; it was a very long sequence, because we kept putting in all these in-jokes and asides and homages to previous episodes… And actually, as a side note, that idea of the museum ship was something I picked up when I did the [Battlestar] Galactica series."

While they were writing "All Good Things…," Moore and Braga were still deep into working on the Star Trek: Generations feature script. And juggling the two got confusing at times.

Moore: "There were points where we literally were working and we would suddenly stop and say, 'Wait, which one are we working on?' [Laughs.] Because they were both two hours, they took place in the same ship with the same characters… and every once in a while, you'd just get caught in the moment of, 'Wait a minute, this scene with Geordi in the engine room is from which one?'"

Braga: "It was an interesting comparison to write a movie and a TV show with the same characters. What we realized was on a TV show, it's like living with your family on a daily basis, and writing a movie is like seeing your family once every four years. You take bigger swings with a movie. Like, we gave Data an emotion chip. You had to do something; it couldn't just be another TV episode. So that's something we learned very quickly. [Pause.] It sounds like I'm teaching a bad screenwriting class."

"He's Jean-Luc Picard, and if he wants to go on one more mission, that's what we're going to do."

If the writing process for "All Good Things…" was hectic, the filming of it was even more so. Not only were they filming a two-hour series finale and preparing to start production on the Generations film, but a documentary crew was also following the actors around taping a "making-of" special at the same time.

Braga: "I do remember the mood on the set was very bittersweet. I think Marina Sirtis [who played Counselor Deanna Troi] might've cried. Literally, as they were filming, they were knocking down sets and rebuilding sets for the movie."

Moore: "It was very chaotic, as I recall, and it was very intense. Yeah, I was on the set for different scenes. We all made a point of wandering down when we could because, again, we were all caught in the moment of, 'It's all ending; go take a good look while you can.' And they were going to start revamping the set for the movie, too, so there was also a literal sense that this was about to go away and be changed. Because they had to do a big rehab on the sets so that they could hold up to being projected on a 50-foot screen all of a sudden."

Braga: "Being on the set for the final shot, with the crew playing poker, we were all thinking, 'Well, we're making a movie next, so this isn't really the end.' But even having said that, I think what was interesting to watch was that the audience's response was a sadness that it was over. Even though they knew there was a movie coming, it would never be the same."

"Five-card stud, nothing wild… and the sky's the limit."

That final scene Braga describes, with Picard finally joining the rest of his crew for their regular poker game, serves as the perfect epilogue to "All Good Things…" — and to seven seasons of TNG. The series ends with Picard dealing and setting the rules: "Five-card stud, nothing wild… and the sky's the limit."

Braga: "There's no doubt at all that my favorite single moment in the episode is 'the sky's the limit' line at the end — a line that, by the way, lived through many iterations. I can't remember what it was… it wasn't 'the sky's the limit.' I think it was first 'aces wild,' and then it was 'no limits,' and it went through so many iterations. I think it was Rick Berman who finally thought of 'the sky's the limit.' But it was an important line, because it's the last line of the series and people really remember it."

Moore: "The poker game had obviously been a motif through the show. And there had been various episodes over the years where the idea of Picard joining the game was kicked around. But then they all got rejected because it felt like it wasn't right, and that would change the character. And then in this ending, it just felt perfect. It might have been [executive producer] Jeri Taylor who suggested that… because it did humanize him and it did take him and bond him to the rest of the characters in a way he had not been. The other characters were a family, and he was sort of the colder, more distant father, and the father was going to join them at the table. There was something beautiful about that that just felt right."

Braga: "It was a happy accident that Picard never really came in to play with the other people. I think we didn't do it because he was the captain. But we never really gave a lot of thought to the fact that Picard wasn't there. It was just something that Riker was into, that Data was into. It hit us, then, how poignant it might be if he did come into the poker game. But it's something that didn't occur to us until we were working on the story. It probably was Jeri's idea. If Ron says it was, I'm sure it was."

Watch the final scene of the Star Trek: The Next Generation series finale right here:

"Goodbye, Jean-Luc. I'm going to miss you… you had such potential. But then again, all good things must come to an end."

Airing on May 23, 1994, "All Good Things…" earned a series-high 17.4 Nielsen rating along with rapturous acclaim from fans and critics, who still count it as not only one of the best TNG episodes ever, but one of the best TV series finales of all time, regardless of genre.

That contrasts sharply with the mixed fan reaction to Star Trek: Generations, which brought Captain Kirk (William Shatner) and Captain Picard together on-screen for the first time, and hit theaters in November 1994.

Moore: "The great irony of it all is, we spent a year on Generations, and 'All Good Things…,' we wrote in a month. We just plowed through it, banged it out. It did not go through radical changes in the drafts. There were production changes, as always, but it was basically what we wrote, pretty close to the first or second drafts. And it turned out beautifully. It was just one of those things where it all flowed and it all came together, and we were astonished by how much people liked it, how much we liked it, how great the final product was. It exceeded your expectations of what it could be."

"And Generations was the opposite experience. Generations, we slaved over for a year; we worked it over and over and over again, and in the end it just fell short. And we were like, God… it was just such a depressing feeling of not being able to bring that one home. But we did have this other experience that was very unexpected and just clicked and became a wonderful piece."

Braga: "Here's the problem: Generations was not a Next Generation film. First Contact was. Generations was a Kirk/Picard film. So there were many masters to serve on that movie. And quite frankly, I don't think it had a good concept driving it. The concept of the two captains sounded good, but they ended up scrambling eggs together… which isn't exactly the most riveting climax you can imagine. But the concept for 'All Good Things…' was far more, I felt, cinematic than the actual movie we made. And, as I have heard many people say, 'All Good Things…' would've made a good movie. And I think they're right. It's the better script. Because it's more pure."

"All Good Things…" not only won the 1995 Hugo Award for Best Dramatic Presentation (only the second TNG episode to win that honor), but it also helped TNG earn an 1994 Emmy nomination for Outstanding Drama Series — the first for Trek, or any syndicated show.

Braga: "Nowadays, there's genre television all over the place: fantasy, horror, science fiction… back then, there was zero. Next Gen was it. And it was a syndicated show as well. So for it to get nominated for [Outstanding] Drama Series was very significant for us. We felt that the show was being recognized. Unfortunately, we lost to David [E.] Kelley for Picket Fences, which, you know… I think we should've won. But it's a testament to [our] show. It was a really good show."

In the twenty years since, Moore and Braga have both moved on from Trek: Moore was the creative force behind Syfy's acclaimed Battlestar Galactica reboot and is currently executive producing Starz's time-traveling fantasy Outlander (premiering Aug. 9); Braga co-created WGN America's supernatural drama Salem (which has already earned a second season) and executive produced Fox's science documentary Cosmos: A Spacetime Odyssey.

But given the chance, Braga doesn't rule out accepting another mission in the Star Trek universe.

Braga: "I would like to say I don't know, but if the opportunity came along, I probably would jump at the chance. And I only say that because I miss Star Trek. I've worked on plenty of shows since, but there's something about the completely wide-open aspect of the show. The simple genius of the concept — where you're just out there exploring, and anything you can dream up is a story you can tell — is something I've never really encountered again. The exploration of ideas… nothing's come close."

Star Trek: The Next Generation is available on DVD (all seasons) and Blu-ray (Seasons 1-5), and is streaming now on Netflix, Hulu Plus, and Amazon Prime.