Ha! Ok.
See, the later into the night you stay awake, the more awake you become, causing spikes of energy such of- whatstheword, spontaneous initiative. Your brain wanders because it doesn't know in which direction this spontinaety is going to take you (for me, it's generally cleaning my room lol), and so then you hear music. Music in general opens up pathways of creativity, but especially softer, more classical kinds of music. So, having a pathway opened through which this spontaneous initiative can travel, it rushed through. <- I should probably mention most of this is from my own observation and not based off of any research, so don't take to it as fact.
And I could go on to say how this doesn't always happen, and the less sleep deprived you are the more likely for it to happen, and why that is. And how that works. But that would take a long time, so... I'd prefer not to.
*bows* Thank you for your attention =P