Google "hypnagogic myoclonus". It's essentially when your brain is switching from manual to automatic. My physiology teacher compared it to the power going out in a building and the generator kicking in; it's rarely a perfectly smooth transition. But yes, it can be more pronounced with anxiety and stress. As was said, sex can help decrease it