Application Idle time

What is the best way of detecting an applications idle time? We want to be able to disable a connection to the application if the user is idle on the application for 'X' amount of time. Thanks, Phil

Loader.
Up arrow icon