patch 8.1.0845: having job_status() free the job causes problems

Problem:    Having job_status() free the job causes problems.
Solution:   Do not actually free the job or terminal yet, put it in a list and
            free it a bit later. Do not use a terminal after checking the job
            status.  (closes #3873)
diff --git a/src/misc2.c b/src/misc2.c
index df3f8e1..657e164 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -6387,6 +6387,9 @@
 	if (job_check_ended())
 	    continue;
 # endif
+# ifdef FEAT_TERMINAL
+	free_unused_terminals();
+# endif
 	break;
     }