Hi Paul,
Should be pretty simple to do this: you want to use the "submit" feature in InfoPath and submit the form to the SharePoint library. There is then an advanced option in the dialog box for submit that gives you various options for what to do with the form after it is submitted - closing the form is one of them:
You don't need any code to do this, it's all in InfoPath by default and all thorugh the controls in design mode.
Good luck!