Seriously, where was the dog supposed to go? Unless he can open doors, he’s literally trapped.
There countless stories of these loyal animals doing this they weren’t “trapped”. You obviously don’t know dogs.