I've heard that you can wake up by closing your eyes in the dream, or by shouting out loud, "I will wake up!" If I'm having a nightmare I'll usually turn around and give whatever person/creature that is scaring me a hug, and ask them what I can do to help them. That usually turns them into something helpless, instead of scary.
It's important to remember that it's just a dream, that you aren't going to be hurt in real life. Tell yourself that being stabbed won't hurt, it's just a dream.