[ticket/13018] Remove duplicate logic in confirm box and alert box handling.

This ensures a more consistent handling of the various closing/opening events and fixes some bugs where certain event handlers are not turned off under all circumstances.

https://tracker.phpbb.com/browse/PHPBB3-13018
I haven't test this, but won't this always equal `!confirmed`? Because fadedark is hoisted, it'll be `undefined` at this point.