STOP ELEMENT BEFORE CLOSE WINDOW