I have this exact problem as well. The dream will be going strong and all of a sudden I'd realize I'm dreaming. Then I instantly wake up. For me I think I figured it out, I think saying out loud that I'm dreaming wakes me up. I don't know why but every time I say it I instantly wake up. The thing is though I can't help to say it and it always happens.

As for you though, from those two examples it looks you did or saw something shocking. Maybe this is waking you up in shock, kind of as a defensive mechanism? Have you tried calming yourself down completely while also stabilizing the dream?