What exactly am I messing up in this control loop?
Safety systems like this generally need to be independent.  Making the door sensor just another input to the controller is a bad idea.

There should be independent circuitry and possibly mechanics that ensures the device is safe when the door is open.  The door sensor could be connected to a main power relay, for example.  In some cases you might also want to release mechanical safety systems, like a brake.