avoidingn a crash while closing the window while editing