A good and simple way to redirect users to the login scree when the APEX application has been idle is to USE the SESSION TIMEOUT TAB
Found Shared Components> Security Tab> Security Attributes >Session Timeout
Maximum Session Length in Seconds: max_length(positive)
On session timeout direct to this URL : f?p=&APP_ID.:LOGIN_DESKTOP:&SESSION.
Maximum Session Idle Time in Seconds :
On session idle time timeout direct to this URL: : f?p=&APP_ID.:LOGIN_DESKTOP:&SESSION. The one highlighted in the RED is the one we considering
Hope this helps