Remove modal-wrapper whenever modal dialog is closed

Old Subject: Issue #5558 and #5548 Dialog fixes

More general fix for issue #5558  (see pull #5559 )
@redmunds
cc @peterflynn

Edit: Incorporated fix for #5548