patch 8.2.2473: crash when leaving command line window triggers autocommand

Problem:    Crash when leaving command line window triggers autocommand.
            (houyunsong)
Solution:   Make sure not to close the current window or buffer.
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index 8ccc753..15d237e 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -2774,4 +2774,13 @@
   augroup END
 endfunc
 
+func Test_autocmd_closing_cmdwin()
+  au BufWinLeave * nested q
+  call assert_fails("norm 7q?\n", 'E855:')
+
+  au! BufWinLeave
+  new
+  only
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab