How to close a popup when clicking on a button in a form

Hi
I have created a contact form popup template. This works fine. I would like to close the popup when the submit button on the form is clicked or rather 10000ms later.

How can this be achieved? I managed to redirect to another page, but I would rather just close the popup and remain on the page the user was viewing.

Thanks for your help