On May 21, 1990, Bob Newhart's second sitcom, Newhart, featured one of the most memorable final episodes in television history.

For eight seasons, the comedian starred as Dick Loudon, an author who left New York to run a rural Vermont inn with his wife, Joanna (Mary Frann). Although it featured an entirely different premise as Newhart's first foray into network comedy, The Bob Newhart Show, the '80s series drew laughs from the same place - with Newhart as the usually calm, lone voice of sanity in an environment populated by eccentrics. It's been the source of Newhart's comedy since his stand-up days in the '60s.

But where The Bob Newhart Show featured Dr. Bob Hartley's neurotic, big-city patients and his timid neighbor, Newhart gave us a spoiled chambermaid, a slow-witted handyman, a yuppie TV executive and a trio of woodsmen where only one of them, Larry, spoke on behalf of his two brothers, both of whom were also named Daryl.

Although Newhart was a ratings success - it never ranked lower than No. 25 in its first six seasons - the star was unhappy with CBS frequently changing its time slot as the network looked to promote newer shows. At a Christmas party, Newhart told his wife, Ginnie, that he thought this would be the last season for the program. She suggested that the farewell episode mock another CBS show, Dallas, where the 1985-86 season had been explained as a dream, when Bobby Ewing (Patrick Duffy), who died in the previous year's finale, returned to the cast. Similarly, St. Elsewhere signed off in 1988 with the revelation that the entire six-year run had taken place inside the mind of one of the main characters' autistic son.

But Ginnie added a twist: Newhart would wake up as Bob Hartley, with Suzanne Pleshette, reprising her role as Hartley's wife, Emily. Pleshette, who was at the party, loved the idea and, when the producers called her two years later, she accepted before they even offered her the job.

Watch Bob Newhart Discuss the Last Episode of 'Newhart'

In the Newhart finale, the town was purchased by a Japanese businessman in order to build a luxury golf resort. Everybody except Dick and Joanna take the money and leave town. But five years later, they all show up at the inn again, as absurd as ever, with the two other Daryls finally speaking, silencing their chatty wives by yelling "quiet!" Fed up, Dick goes to walk out of the inn, but after opening the door, a golf ball strikes him on the side of the head and knocks him unconscious.

He then wakes up in the bedroom of the Hartleys' Chicago apartment, which was rebuilt for the Newhart episode. Dick rustles Emily to explain the dream, describing the oddball characters. "That settles it," she replies. "No more Japanese food before you go to bed."

Still, she wants to know more about the beautiful blonde he described as his wife. "Go to sleep, Emily," he says. "You know, you really should wear more sweaters" - a reference to Joanna's preferred choice of outfit. The screen then goes to black for the final time.

Watch the Last 10 Minutes of 'Newhart'

Worried that the surprise ending might leak to the tabloids, Newhart had the writers create a fake ending, with the golf ball killing Dick, at which point he goes up to heaven and meets God, played by either George Burns or George C. Scott. Pleshette said that she was even given a code name for when she had to call the producers to make arrangements to show up at the studio.

Only the writers and director Dick Martin were in on the surprise, with the cast being told on the morning of the shoot what was really happening. The crew learned that there was a new last scene when they came back from dinner break. By then, the Hartleys' bedroom had made its way onto the set and was covered by a curtain; the camera operators were told where they should be located. To top it all off, the actors had to nail the scene on the first take.

Watch Suanne Pleshette Discuss the Last Episode of 'Newhart'

"They hid me in a trailer for six hours with no phone," Pleshette recalled. "We were so nervous, because we couldn't rehearse. I said, 'Jesus, Bob, if that light fixture isn't where it was in 19 ... whatever the last year was ... I'm gonna be wham-banging on the wall until the lights come down."

In the darkness, Pleshette was whisked onto the set with her face covered as she got under the covers. "Bob and I were holding hands and he said, 'Wait for the laugh.' And I said, 'What if there isn't one?'

There was no need for either of them to worry. As soon as Newhart turned on the light, the audience recognized the old set. And when Pleshette was revealed, a 15-second ovation took place before she could even speak. As soon as she heard the screams from the audience, she "knew it was a piece of television history. And he knew it. We knew it."

Enter your number to get our free mobile app

Rock's 60 Biggest 'Saturday Night Live' Moments