You can set your QINACTITV (Inactive job time-out) and QINACTMSGQ (Inactive job message queue) system values.
The subsystem will check every x minutes (where x is value of QINACTITV) for inactive jobs and mark all those that it sees. The next cycle the subsystem will take the action provided by QINACTMSGQ (either end or disconnect job) for all jobs that have been inactive since the last cycle. I've included a link that goes into more details.
https://www.ibm.com/support/pages/qinactitv-system-value
#IBMi#SupportMigration#Support