I ran into this issue the other day while streamlining our terminal components, mainly being able to access the text and perform actions on the screen in order to close out of the screens and window so a new terminal connection can be made.
There was no way to attach a terminal connection to an already opened window. However, you should be able to create a new terminal connection and pass the connection variable to other Terminal Session activities.
So my answer is for if the terminal window is opened prior to the job running, which then you will need to use some workarounds to close the window (assuming you can’t just hard kill the window).
Basically, I used a combination of the below:
Element Exists // to check if an instance of the terminal window is opened
Text Exists // to verify you are on a specific screen in the terminal window
Sent Hotkey // to perform navigation of the screens
Type Into // to perform actions on the screen
and Close Window
I placed all this in a Retry Scope, so I can close all terminal instances that are opened. Once there are no instances, then the job will be able to start a new Terminal connection.
This might not be the ideal solution, but this was just some input based on my prior experience.
And, like I said, if your job starts a new Terminal Connection you should be able to pass its output variable to other Terminal Session activities; it works fine for me.