form close button logic