That happened to me, too. After a few of those I was able to stay in the dream. I guess I got so excited that I woke myself up.

Before bed give yourself the suggestion that you will stay relaxed and asleep when you realize you are dreaming.