[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
`fadedark = fadedark || true`?