Sounds like you want a 'lock' on the door, which will close it (if necessary) and lock it when triggered.
To close it only if it's open, you can keep track of its position using a global variable, set by an env_global.
To lock it, you need a Master (a multisource) for the func_button that opens and closes it. The Master doesn't trigger it, it provides a permissive for the button to work. When the Master is 'on,' the button will work. By setting the Master to 'off,' it will prevent the button from working.
Lemme see if I can throw an example together this evening.