What is interesting is both of those episodes were written by writers not known for drama. Richard Curtis (Vincent and the Doctor) is most famous for the Blackadder, Bridget Jones Diary, Vicar of Dibley and Love Actually, and Neil Gaiman is most famous for Sandman, Stardust, Neverwhere and American Gods. It is also noteworthy that neither writer was sacred of a sad ending.
The inherent underpinning of great comedy and great fantasy, of great writing no matter the genre, is great heart.
Here is the entire song, one of the rare times they used a popular song, from Vincent and the Doctor: