My handlebar and My front tube are no longer one. Might I have died? So, I have this problem [problem].  

This happened today while I was putting it in a car to store overnight, but clearly I have to fix this.

Could someone please tell me: what exactly qent wrong here, and how likely would this have been to kill me?

Just in case it is hard to see, this is my handlebars coming off of my stem....
This is a "quill stem" and uses a "wedge" or an "expander" to press against the inside of the steerer tube (the top part of the fork.)

When fitted correctly, the quill stem sits in the fork and is held in place because the grey part at the bottom is pulled up by a long thread and it is pressing against the inside of the fork. Here the thread that pulls up the bottom piece must have been come loose or broken.

If this happens quickly it is dangerous because you no longer can steer the bike with the handle bar and quite likely will crash. If it happens slowly you will find that front wheel and handle bar are no longer properly aligned and this would trigger you to inspect it.

I can't answer how likely a fatal accident would have been but count yourself lucky to have noticed the problem.