There are several different methods that you can use to end an interactive job.
You can also request the subsystem to send a message to a message queue when an interactive job has been inactive for a specified period of time. You, or a program monitoring that message queue, can then end or disconnect the job.