There are some things you can't explain to a dog. she doesn't understand why you're hurting her, she doesn't understand why you don't want the door open. So you have to make it so she can't do those things. Baby gates, door locks, etc. Even the best-trained dog in the world (which you won't get by hitting) doesn't grasp some concepts.