patch 9.0.0397: :defer not tested with exceptions and ":qa!"

Problem:    :defer not tested with exceptions and ":qa!".
Solution:   Test :defer works when exceptions are thrown and when ":qa!" is
            used.  Invoke the deferred calls on exit.
diff --git a/src/main.c b/src/main.c
index 7a42463..2a2dcb0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1583,6 +1583,11 @@
     if (!is_not_a_term_or_gui())
 	windgoto((int)Rows - 1, 0);
 
+#ifdef FEAT_EVAL
+    // Invoked all deferred functions in the function stack.
+    invoke_all_defer();
+#endif
+
 #if defined(FEAT_EVAL) || defined(FEAT_SYN_HL)
     // Optionally print hashtable efficiency.
     hash_debug_results();