patch 8.2.4454: resetting cmdwin_type only for one situation

Problem:    Resetting cmdwin_type only for one situation.
Solution:   Reset cmdwin_type before closing windows. (closes #9822)
diff --git a/src/testdir/test_exit.vim b/src/testdir/test_exit.vim
index 7e50e78..c05374c 100644
--- a/src/testdir/test_exit.vim
+++ b/src/testdir/test_exit.vim
@@ -119,6 +119,7 @@
   call writefile([":au VimLeave * call writefile(['l = ' .. v:exiting], 'Xtestout')", ":tabnew", "q:"], 'Xscript', 'b')
 
   if RunVim([], [], '<Xscript')
+    call assert_equal(1, v:shell_error)
     call assert_equal(['l = 1'], readfile('Xtestout'))
   endif
   call delete('Xscript')
diff --git a/src/ui.c b/src/ui.c
index bf6ea85..a6cee80 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -1065,9 +1065,6 @@
     if (silent_mode)	// Normal way to exit for "ex -s"
 	getout(0);
     STRCPY(IObuff, _("Vim: Error reading input, exiting...\n"));
-#ifdef FEAT_CMDWIN
-    cmdwin_type = 0;
-#endif
     preserve_exit();
 }
 
diff --git a/src/version.c b/src/version.c
index 57f32cb..5da1833 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    4454,
+/**/
     4453,
 /**/
     4452,
diff --git a/src/window.c b/src/window.c
index 7da7b89..ceb7d59 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2856,6 +2856,10 @@
 {
     int		dummy;
 
+#ifdef FEAT_CMDWIN
+    // avoid an error for switching tabpage with the cmdline window open
+    cmdwin_type = 0;
+#endif
     while (first_tabpage->tp_next != NULL)
 	tabpage_close(TRUE);