Refactored modal closing way.