Yup, that's how The Man with The Metal Glove was born. I got the urge to write a short scene about a guy with a metal glove showing his comrade an important enemy's dead body(which was inspired by a creepypasta I wrote, and that was inspired by the title of another story... it's complicated), and the moment it was born, it grew and grew, and demanded milk and words and food, and now I can't stop feeding it or It'll die(and I would be arrested for child abuse).
I get those sudden moments of inspiration as well, but if I'm at work or for some other reason can't write it down atm I just keep thinking of it and develop the idea in my head until it's so anchored that I won't forget about it. I like your example about the music-creation, I think writing music and writing novels has a lot in common.