You can use a relay that is wired by(for example) to the door hazard light as it's switchable current powering the relay's internals and to the ignition wire going into the HU..this path will be opened or closed depending upon the state of the door lightbulb(lit or unlit). So, when you open the door the door light will trigger the relay to open the circuit to the ignition current, thus turning off the HU. Close the door the circuit is now closed and HU is playable.
Of course for the above to work you need two parameters, the ignition must be in the "on" position and door to be closed.
Interesting, but nonethless pointless idea Research up on relays and try it out, it seems like a pretty simple electrical experiment.
There's a way to link 2 relays so they'll stay on until broken, and then stay broken until deliberately reset - if you wired that using the driver's door pin switch as the break trigger, and then reset using the key's switched power, that'd do what you wanted. As mentioned, search on the net for wiring diagrams, they're all over the net.