I’ve noticed that this topic has been asked about by many people and I thought I’d offer up what I did to eliminate this problem.
The trick I used was to open the form in a dialog. That way, when you click Cancel, the dialog is dismissed and you remain on the same page from which you opened the dialog.
Here’s some example html.
In this case, uploadfile.aspx is located in the pages library and is a custom page with an InfoPath form web part on it. The custom page also has a URL filter on it that is connected to the form. The parameter, ProjectID, is a URL parameter that is passed to the form through a web part connection.
Here is an image that has the above hyperlink (Upload File) anchored to it.
This opens the page below in a dialog. Notice how the Project ID is defaulted on the form using a URL parameter that is sent to the form web part using a web part connection.
When Cancel is clicked, the dialog is dismissed and we’re right back where we started.
For the "Thank you" page, I’d recommend creating another view in InfoPath and simply switching views after the submit with your "thank you" text and provide an OK button to close the form.