How to exit a form after a certain elapsed time

I want to exit a form after say 5 minutes of inactivity from the user. How should I implement this in my custom actions? I saw the documentation of forms but there was nothing mentioned about time bound deactivation of forms. Please help if anyone knows how to implement this. Thanks.