Playing to his strengths, Bob Newhart toplined two CBS comedy hits — “The Bob Newhart Show” and “Newhart” — and finished their combined 14-year run with one of the greatest farewells in TV history.

“Those two series gave him a vehicle that enabled him to do what he does best,” says Barry Kemp, “Newhart” creator and exec producer of the sitcom’s first two seasons. “He was put into situations where he could react to some fairly bizarre people around him.”

In “The Bob Newhart Show” (1972-78), a steady stream of colorful characters flowed into the practice run by Dr. Bob Hartley, the mild-mannered Chicago psychiatrist played by Newhart. Workplace regulars, such as the brash receptionist (Marcia Wallace) and bachelor orthodontist (Peter Bonerz), had their quirks, as did the neighbors in the high-rise apartment Hartley shared with his wife, Emily (Suzanne Pleshette).

Absent, for the most part, were kids, allowing the writers to focus more adult-oriented storylines, says Michael Zinberg, a writer, director and producer on the series. For example, in the 1977 “Ex-Con Job” episode, Hartley led a group therapy session at a prison, and in the 1975 Thanksgiving show, “Over the River and Through the Woods,” he begged out of a trip with Emily, and instead spent an alcohol-infused holiday with his buddies that included a classic call to a Chinese restaurant for moo goo gai pan.

The comedic situations connected with viewers who tuned in on Saturday nights, and also with in-studio audiences.

“It was fun watching the cast perform and do the show, and then hearing the audience respond to it,” Zinberg says. “I used to mix the soundtrack before it went on the air, and there were a miniscule number of edited laughs. It usually was the real audience.”

For “Newhart” (1982-90), Newhart returned to primetime with a new wife (Mary Frann) and a new life, as Dick Loudon, the harried owner of a colonial-era inn in scenic Vermont.

As it turned out, rural New England also was populated with eccentric characters, including George (Tom Poston), the inn’s slow-thinking caretaker, and Larry, Darryl and Darryl (William Sanderson, Tony Papenfuss and John Voldstad), three backwoods brothers who eventually take over the local cafe.

“The writers would come in with their own stories and say, ‘You know who’s really weird in my family?’ and characters would evolve out of that,” recalls Bob Bendetson, an exec producer and writer on the series. “We went very broad with them, but we always treated them as though they really existed. They were sort of quirky, small-town characters, and Bob would react in the way he would react — that these people are crazy.”

The series signed off on May 21, 1990, with what Entertainment Weekly earlier this year praised as the best TV series finale ever. In “The Final Newhart,” Dick Loudon is hit in the head by an errant golf ball and knocked unconscious. He then wakes up as Bob Hartley — with Emily in bed next to him — and tells her about his strange dream about living in Vermont and running an inn.

Also impressed by the sendoff was Kemp, who had moved onto another series, but returned to watch the taping of the finale. “Going back and completely recreating that bedroom,” he says, “where so many scenes took place between Bob and Suzanne, I thought that was really, really smart.”