Original: As they leave, he locks all the bedroom doors to prevent the intruder from escaping.
Simplified: As they leave, he locks all the bedroom doors to stop the person in the cupboard from escaping.