Hi Bickle
To CLose the form using code:
thisXDocument.View.Window.Close(true);
For further more idea look at the following links:
http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=1961
http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=194
Madhuri
http://www.ggktech.com