[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
Why are you passing the event in instead of calling `.preventDefault()` and `.stopPropagation()` here? It doesn't seem very clean—what does closing an alert have to do with a click event somewhere else? Sure, one causes the other, but I don't think they're related enough for the close function to handle the event.

Your call, though.