added check for close button