Another way to achieve this is purely at the database level, where you could CREATE A PROFILE.
Assign this profile to all your users. Then if the user is IDLE for the amount of time specified in the IDLE_TIME parameter, the server will disconnect the user.

This approach does not require any changes to your front-end code. You do need help from the DBA and or system level permissions on the database to achieve this.