Moving my answer from closed dupe
From client-side managed code, which is no more than add-on:
Application.Quit();
and
this.Close();
are available and work in Infopath Filler Form.
It is not available in Web Browser Form (because it is run through remote Sharepoint Server 2010's Infopath Forms Services).
Here are possible workarounds:
- setting a bogys submit with a close on submit, calling Submit() from code
- embedding Infopath form Web Part in ASPX page, closing it from its code
From server-side (external to Infopath code), you should pass a reference to a XML (form) document being closed