quit program on idle

First off I have to admit I have no scripting experience.

Scenario:
We need access to a single email account from 7+ different machines and if you have more then 4 users connected to it at any given time it will block the last 3 users from connecting to the email. None of the users are remembering to close the application when they are done checking their email.

Basically I need a script to watch for the program to become idle idle and then quit the application after 5 or ten min.

You don’t reveal nearly enough. Where and what is the mail program you want to watch? What OS are we talking about?