I'm not sure you need to leave the room and there may be a lot going on in that action...Walking out of a room might take 5-10 or more seconds, that's a lot of time between the behaviour and the 'punishment'. Some dogs are already dreaming of cookies after 2 seconds, lol.
I would try the yelp, and immediately stand up and turn in the opposite direction of the dog with arms folded so that your backside is the view he gets. That should take 1-2 seconds. When the dog settles, or maybe after a "sit", try again. Just a thought. Good luck!