Do you mean terminating an active APM session without logging in to APM? Or are you referring to a TCP session?
For APM sessions to be terminated using iRules, you can use the "ACCESS::session remove" command. (See some examples here: https://clouddocs.f5.com/api/irules/ACCESS__session.html)
To make sure this automatically happens after a certain time will be a bit trickier though - as iRules are normally event-driven and they don't just run in the background. Maybe someone else around here may have an idea for that.
Alternatively, if you want to do this for all sessions, you can also change the timers in the policy itself (there is the Maximum Session Timeout value) which will kill off a session no matter if it is still actively used.
If you want to ensure that only certain users get kicked off after a certain time, you can also update the Maximum Session Timeout value using an iRule and the "ACCESS::session data set session.max_session_timeout 1000" string - this will change the value of the maximum session length to whatever value you want, in this case to a 1000 seconds.
Hope this helps.