If you're in a door frame, and the door is close whilst you're not there, you will re-spawn inside the door and get stuck. You just need to add something to the existing trace you do on player spawn to stop that happening.