When I'm trying to sleep but still awake, I sometimes get dream-like thoughts. I still twist and turn in bed, consciously moving (thus not sleeping) and hearing sounds in the room, but these thoughts are definitely dream-like in the sense that they're usually quite random.
Example: I'm walking in a park, talking to a someone about a specific subject, seeing flowers, trees, whatever.
At one point I realise this and consciously 'say' to myself: "if I want to, this entire train of thought is completely gone". Right after thinking this, the 'dream' is almost completely erased. I generally still do know the general subject (I'm in a park), but everything else is completely gone. I try and I try to remember the rest, but none if it comes back. I cannot even recall the fact that - in this example - I was talking to someone (let alone who) and what scenery I was surrounded with.
Is there any name for this mechanism? It always confuses me.