Now that I think about it - the existing secondary animation system should pretty much already allow for everything needed here. The only changes that may be needed, are:
- firstly, the ability to have an animation that plays only once when a condition is fulfilled - or alternatively, that loops back to a specified frame, instead of always to frame zero
- secondly, the ability to play a sound when closing
- (and maybe, thirdly, the auto-generation of a "opening, but backwards" animation; for those without such an animation, perhaps a red "X" placed over the exit could work)
Beyond this, all that's needed is careful use of the secondary animation system.