You can’t — it’s a natural, human urge. Without such instinct, we wouldn’t want to procreate and carry on the race. Thus, it’s pretty much hard-wired into your brain. While you can never stop the actual urge, you can increase your own self-control and willpower. Just don’t do it, regardless of how badly you want to. Distract yourself with something else. Although, I do want to say that there is nothing wrong with masturbation (or doing it as much as you want).