Psychological function, probably because I watch too many ghost movies and always like to think about some messy things. I have the same situation. I was fine when I was young. Now when I sleep alone, I think about a bunch of messy things, ghosts and so on, which frighten me to sleep or wake up from nightmares.
At this time, I will play Diamond Sutra or Tao Te Ching, which still works. I suggest you try Faye Wong's Diamond Sutra.
Finally, to sum up myself, I feel that it is still related to my health. When I have enough rest and don't stay up late, this situation will basically not happen.