They could be part of HI. During hypnagogic imagery some people see short dream-like segments; they come from their conscious brain pulling up or registering random images and memories from the subconscious as it sorts through the day.

Or it could just be your normal process of going to sleep; I don't want to wrongly label something. I used to experience that almost every night--I'd sort of slip in and out of consciousness and random dream scenes would unfold. The illusion would pull me away from consciousness, and I would either fall asleep or wake up and realize I was sort of dreaming. Either way, your thoughts aren't going crazy. What you're seeing is a natural part of falling asleep.