When it just about at the end of the hallway the monkey triggers something. By the time it reaches the door, a wall has started to slide across the hall, trapping the monkey between it and the doorway.  If that is the entrance, then the monkey will be proceeding on his own.