In InfoPath, you can create a custom button using your own custom software code. To create a custom button using code:
To create a button that will submit an InfoPath form and close the form, include the following line in your code:
NotifyHost("Submit&Close");
To create a button that will close an InfoPath form without submitting the form, include the following line in your code:
NotifyHost("Close");