patch 9.0.0822: crash when dragging the statusline with a mapping

Problem:    Crash when dragging the statusline with a mapping.
Solution:   Check for valid window pointer. (issue #11427)
diff --git a/src/window.c b/src/window.c
index 8d61def..5a9440a 100644
--- a/src/window.c
+++ b/src/window.c
@@ -4249,6 +4249,7 @@
 {
     tabpage_T	*tp = curtab;
 
+    reset_mouse_got_click();
 #ifdef FEAT_JOB_CHANNEL
     leaving_window(curwin);
 #endif
@@ -4464,6 +4465,7 @@
     // Don't repeat a message in another tab page.
     set_keep_msg(NULL, 0);
 
+    reset_mouse_got_click();
     skip_win_fix_scroll = TRUE;
     if (tp != curtab && leave_tabpage(tp->tp_curwin->w_buffer,
 					trigger_leave_autocmds) == OK)