patch 8.2.5045: can escape a terminal popup window when the job is finished

Problem:    Can escape a terminal popup window when the job is finished.
Solution:   Only check for a finished job where it is relevant.
            (closes #10253)
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index 950edf2..3a0f876 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -2907,6 +2907,9 @@
   let lines =<< trim END
       vim9script
 
+      # testing CTRL-W CTRL-W requires two windows
+      split
+
       term_start(['cat', 'Xtestfile'], {hidden: true})
 	  ->popup_create({
 	      minwidth: 40,
@@ -2925,9 +2928,13 @@
   call term_sendkeys(buf, "50%")
   call VerifyScreenDump(buf, 'Test_popupwin_poptermscroll_2', {})
 
+  " get error if trying to escape the window
+  call term_sendkeys(buf, "\<C-W>\<C-W>")
+  call VerifyScreenDump(buf, 'Test_popupwin_poptermscroll_3', {})
+
   " close the popupwin.
   call term_sendkeys(buf, ":q\<CR>")
-  call VerifyScreenDump(buf, 'Test_popupwin_poptermscroll_3', {})
+  call VerifyScreenDump(buf, 'Test_popupwin_poptermscroll_4', {})
 
   call StopVimInTerminal(buf)
   call delete('Xtestfile')