Why do I get so many ideas right before I fall asleep?

Why, indeed, does my mind suddenly awake when the rest of me should be falling asleep? I have a theory. Most of the day, the part of my brain that deals with logic, following established procedures, and critique, is awake. It is quite useful, as it allows me to recall the proper way to do household chores, the correct way to spell a word, and the practical range of a given instrument so that I…