For years, anyone watching a program they like with a sense of TV history has screamed a warning as sexual tension between characters is about to be consummated: “Stop! Save yourselves! Your fictional lives depend on it!”

The same fear initially applied to “The Office,” which, against all odds, has managed to survive the from-afar, consummated, long-distance, on-again, engaged romance of Pam (Jenna Fischer) and Jim (John Krasinski), providing the human foundation to a series that otherwise specializes in quirks and eccentricities.

Although the British version of the program (or “programme,” as they quaintly spell it there) had its own version of Pam (actually, Dawn) and Jim (Tim), that scenario hardly offered a blueprint for adapting the story to a U.S. comedy that has now run five seasons. Indeed, the U.K. incarnation yielded a mere 12 installments before wrapping up — and satisfyingly resolving its romantic plot — in a special finale.

Much of the credit goes to the writers and performers involved, and it’s a testament to their talents that Pam and Jim have recently enjoyed a relatively stable, even happy relationship — despite her impulsive decision to join boss Michael (Steve Carell) in his stand-alone business endeavor — without sending that key aspect of the show toppling into disarray.

To appreciate that feat, a bit of history is in order. Television series have long simmered in unexpressed sexual chemistry, famously highlighted by programs such as “Cheers” and “Moonlighting.” In many instances, even when the writers insisted romance wasn’t in the offing, they ran out of options (think “The X-Files”) and eventually succumbed to temptation.

The problem — and it’s certainly not a small one — is that allowing your squabbling leads to stumble into bed with each other is, in the parlance of bigscreen romantic comedies, where the movie traditionally ends. Nobody really wanted to watch Gable and Colbert continue in marital bliss — indulging in kinky “blow down the walls of Jericho” foreplay — after “It Happened One Night.” Knowing they wound up together ever after, presumably happily, is enough.

Similarly, uniting Maddie and David on “Moonlighting” left the show fumbling for what to do next, just as “Cheers” became a significantly lesser commodity once Sam and Diane hooked up. Frankly, the latter was salvaged — and able to run smoothly for another six years — by Shelley Long’s midrun departure, eliminating what became an increasingly awkward dynamic.

“Frasier” survived its supporting-star pairing, too, but the show was never better than when David Hyde Pierce’s Niles was secretly pining for Jane Leeves’ Daphne. And one can argue that “Grey’s Anatomy” has come close to wearing out its welcome with many fans simply by exhausting (and re-

exhausting) so many romantic entanglements, to the point where the sexual history of the George character alone has become cause for derision.

In most instances — and “The Office” hasn’t been immune to this — taking the romantic plunge has subsequently required erecting some arbitrary impediment to again pull the same characters apart, usually with varying degrees of credibility. Mindful of the fact that happy couples are hardly the fixings for good drama (and can be equally challenging in comedy), writers thus find themselves dismantling romances that they have meticulously labored to inspire the audience to root for — as evidenced by the visceral thrill of the “Office” second-season finale, when Jim finally let Pam know how he felt about her.

The durability of “The Office” notwithstanding, all this suggests that producers would be wise to look and think hard (that’s what she said) before allowing their stars to leap into bed with each other. The show you save might be your own.