There's a game setting that determines how close wolves and bears can be when you leave an interior space. Generally the higher the difficulty, the closer they can be.

Tossing rocks near wolves/bears is a bad idea if you're already in danger, as they'll react just as if you'd aimed a gun or bow at them and enter their charge state immediately if they're aware of you already.