updated for version 7.3.545
Problem:    When closing a window or buffer autocommands may close it too,
            causing problems for where the autocommand was invoked from.
Solution:   Add the w_closing and b_closing flags.  When set disallow ":q" and
            ":close" to prevent recursive closing.
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 8d9ceb7..6740a51 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -6459,7 +6459,9 @@
     }
 #ifdef FEAT_AUTOCMD
     apply_autocmds(EVENT_QUITPRE, NULL, NULL, FALSE, curbuf);
-    if (curbuf_locked())
+    /* Refuse to quick when locked or when the buffer in the last window is
+     * being closed (can only happen in autocommands). */
+    if (curbuf_locked() || (curbuf->b_nwindows == 1 && curbuf->b_closing))
 	return;
 #endif