Preventing accidental close of window