How do you stop a dog from peeing when scared?

well its natural for a dog to do that but if you can stop it from getting scared by whatever it is then you can stop the pee!