Belov’d of seventies and eighties US cop shows, the Cosy Comedy Gag ending appears to have developed as a syndication buffer. What it actually consisted of was a back at base coda to the show. No matter how dramatic that weeks episode of The Streets Of San Francisco got, you could get back to the patrolroom where in about a minute all the regular characters can check-in, get a line, show that nothing really has changed from the start of the show and tell a nice, light gag. The gags were often terrible, and the coda absolutely pointless. But it was a useful way of ending the show because

a) In syndication it could be chopped out to make way for more ads.
b) It really did reset the show. If a character was injured, they would be seen to be recovering in the coda. Often one of the leads might get stung by a girl in love (she would always turn out to be the baddie). The coda was the way out of the heartache.
c) This meant that episodes could happily be shown out of order without annoying the audience.
d) The moral could be made crystal clear if there was one (HELLO HE-MAN)
e) Philosophically it stressed the idea that nothing in life is really serious or life-changing.

Fundamentally, it is an ending that is not an ending at all. Unlike a soap, which would trail endlessly to the next episode, the Cosy Comedy Coda basically obliterated the existence of the episode which preceded it. Nothing that happened in the show was meant to be remembered beyond the warm fuzzy of being entertained. Whilst containing the idea of ending, without adding any real closure, it is almost an anti-ending. Which is what makes it quite interesting.

Programs rarely do this any more (except maybe Monk). Which is a pity. Because the craft in wrapping up everything at the end of an episode of Quincy, and fitting in a gag was serious scriptcraft.