I keep a notebook on the nightstand. If I wake up thinking of something, I just write it down. Then I can fall back to sleep almost instantly.
I learned to do this for two reasons, I learned that if I thought of something and didn't do something about it, it would either keep me awake until I was really fatigued or I would wake up knowing that I thought of something but couldn't remember what. Then it would nag at me most of the day until I either remembered it or couldn't.
I get ideas for fixing things, or suddenly remember where I saw that one specific photo, or things like that. I have learned that my subconscious is sometimes far smarter than when I am awake, so when someone told me to keep notes, I jumped at the idea.
Now, if only I could remember who told me about using a notebook,,,,,I think it was in a Heinlien book,,,,,,,maybe I will write it down tonight,,,,,can't think of it right now,,,,,,,we'll see in the morning.