It’s virtually unheard of for a star to leave a hugely successful TV show during the height of its popularity, but that's exactly what happened when Shelley Long exited Cheers in 1987.

Long was one of the show's original cast members. The series premiered in September 1982 and initially seemed like it wouldn't be around for long. Ratings were so low in the first season that the show ranked 74th out of 77 shows. Still, NBC stuck with it, and by 1984 Cheers had become a comedy juggernaut.

Though the series boasted a talented ensemble cast, the romance between Sam Malone (Ted Danson) and Long's Diane Chambers had become the focal point, with fans tuning in every week to follow along with the relationship.

Watch Sam and Diane on 'Cheers'

Long won an Emmy for her portrayal of Diane, the high-brow, well-educated waitress working in Malone's bar. Network executives had hoped to extend her five-year contract, but the actress decided to leave the show to focus her attention elsewhere.

"It was a very difficult choice to make," Long admitted at the time her departure was made public. "We have done some really terrific work at Cheers, but I've decided to give priority to my family and my newly established film production company."

Long's film career had been taking off thanks to leading roles in the movies Night Shift (1982), Irreconcilable Differences (1984) and The Money Pit (1986). Whether she'd outgrown Cheers or simply wanted a change of scenery, she'd made up her mind that it was time to go.

"Our jaws dropped when we found out she was leaving," writer David Lee admitted to GQ decades later. "From a writing standpoint, you would look at [Sam and Diane's] scenes and go, 'That's the glue that's holding everything together.'"

"There was a lot of concern that Shelley leaving would cause the show's downfall," producer Ken Devine recalled, "so everyone's livelihood was at stake."

Those concerns weren't just felt among the crew, but the cast as well.

"I was scared," Danson admitted. "Could I be any good? Would people want to watch one half of the relationship? She put Cheers on the map. Was she the entire show?"

Watch Sam and Diane on 'Cheers'

Naturally, a decision as impactful as Long's caused a ripple effect. Fans who had eagerly anticipated a Sam and Diane wedding would now be saying goodbye. The biggest challenge would be creating a reason for Diane's departure that was believable and sympathetic, without doing anything to make the show's remaining characters unlikeable.

Brothers Glen and Les Charles had created Cheers alongside Jim Burrows, and the three men would take it upon themselves to write Long's final episode.The trio reportedly still didn’t have a script written one week before the episode was to be shot. Ideas tossed around included: Sam and Diane get married, only to discover their relationship was all based on the chase and they don't actually want to be together; Sam and Diane have a child, and Sam somehow becomes a single father and has to balance a baby with his bar life in the next season; Sam and Diane break up, but it's not shown onscreen and instead gets relayed by the show's other characters. None of these would prove to be the right formula.

Instead, the show creators went back to the first Cheers episode. When the world met Diane Chambers, she was a Boston University graduate set to marry her college professor, Sumner Sloane. In the pilot, Chambers was ditched at the titular bar while her would-be fiance rekindled his relationship with his ex-wife. Diane's final episode would bring Sloane back, just as she and Sam are getting ready to marry. The professor has some news: Publishers are interested in one of Diane's manuscripts that he submitted without her consent. Finishing the book would take a lot of work, something settling down and starting a family wouldn't allow. In the end, Sam encourages Diane to pursue her dream, putting their wedding on hold the day they're supposed to be married.

In the famous final scene, Sam and Diane say their goodbyes, with the latter promising she’ll return in six months. "Have a good life," Sam replies. "Have a good life?" a stunned Diane responds. "Well, that's something you say when something's over." The baseball player-turned-bartender then rattles off a series of hypothetical things that could happen before the lovers see each other again. In response, Diane reassures him she'll return in six months, then turns and walks out the door. "Have a good life," Sam says one last time.

Watch Diane and Sam Say Goodbye

Partly because they wanted to keep it under wraps, and partly because producers thought Long might change her mind, three endings to the episode were shot. Only one — the version where Sam and Diane actually tie the knot — was seen by a studio audience.

When Long's final episode, officially titled "I Do, Adieu," aired on May 7, 1987, it was the most-watched show of the week, with more than 24 million households tuning in. Critics were split on the episode, with some praising the way Diane's departure was handled, while others found it too contrived.

Long's departure would open the door for Kirstie Alley, who arrived as Rebecca Howe in season six. While Cheers would initially see a slight dip in ratings after Long left, the sitcom would soon rise to new heights, eventually becoming the most-watched show in America.

For her part, Long never regretted the decision to leave. She returned as Diane in the series finale in 1993.

Meanwhile, series co-creator Les Charles believed the actress' decision forced him and his team to make Cheers even better. "I remember one critic saying, when Shelley walked out that door, 'There goes Cheers,' he recalled. "And for all we knew, they might have been right. But we said to ourselves, "We're not going to do another romance. We're going to find something different."

28 Classic Films That Were Turned Into (Mostly Failed) TV Shows

Many classic '70s and '80s flicks have spawned TV series - but few have found success. 

More From 92.9 NiN