Seems like you can sometimes block him from exiting the locker if you time it right by opening the locker and quickly moving to the tile he's supposed to spawn at (even though that should just displace him, for some reason it doesn't happen).
I've done some changes so that this doesn't happen anymore.