Added handler to check outside the widget when it's closed.
Refactored some code to adapt the static MessageBox to the new implementation