Harry is locked in the safe after the safe door is lightly struck by Art opening the office door. Safe doors weigh hundreds if not thousands of pounds, far too heavy to casually swing shut. Further, large safes are locked by thick metal rods that must be locked in place by turning a lever or wheel. Even if the door had swung shut, it would not have locked without deliberate action from outside.
When Harry turns on the small flashlight inside the safe, the light that illuminates him is obviously being shone on him from off-screen.