Making a while-loop timeout

unsigned long startedWaiting = millis();
while(doorNotClosed && millis() - startedWaiting <= howLongToWait)
{
   // Keep waiting for door to become closed
}

All you need to do is substitute something for doorNotClosed, whether that is a boolean variable or a function call is up to you.