How I Met Your Mother was one of those TV sit-coms that managed to bring humour and friendly warmth to every incident its characters faced – whether good or bad. Now, two years after the show went off air, its creators Carter Bays and Craig Thomas have revealed that the inspiration behind the CBS hit was one of the worst moments in American history – the 9/11 terror attack.

The showrunners explained the origins of the idea for the show during a keynote discussion at the New York Television Festival on 24 October. "It really was a 'do it now or never do it' moment. Life is short — this is something we want to do eventually, we should do it," recalled Bays, who along with Thomas were working as staff writers on Late Show With David Letterman back in 2001.

While seeded in tragedy, the duo decided to write a playful, emotive script. "We have to write something bigger and with emotion, and [that] talks about twists and turns in life," Thomas explained of the idea.

Bays added, "It informed HIMYM in very subtle ways. For two 29-year-olds to be writing something so nostalgic... [Because we learned:] Wow, life really is about chapters closing and things coming to an end, and things pivoting on an axis that will never pivot back."

The show, which starred Neil Patrick Harris, Jason Segel, Cobie Smulders, Josh Radnor and Alyson Hannigan went on to run for nine seasons before ending in 2014. "HIMYM wasn't the funniest show, it wasn't a joke machine like Big Bang Theory. The thing I take away is: How do you do something that maybe nobody else is doing? ... Find your little superpower that only your show can do, and do it," Thomas opined.

Carter Bays and Craig Thomas
How I Met Your Mother creators Carter Bays (L) and Craig Thomas talk about the show Frazer Harrison/Getty Images