Adding support to stop closing on close button clicked