As @Laurie has suggested, this may be a problem with the Source parameter in the query string used to open the form. Does the form close correctly when using the default forms library UI to open it?
If an error is occurring, the place to look is in the SharePoint ULS logs on the server. This is true for any error that occurs in SharePoint that lacks the detail you're looking for. There's a list of tools to assist herelist of tools to assist here.
(If you don't have access to the server, ask your systems administrator to copy the log files for you that correspond to the time the error occurred.) For SharePoint 2007 you'll find them at:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\Logs
You are then looking for something to show in the logs at almost the exact time the error occurs on the screen. It will have a category of something like "InfoPath" or "Forms Server". If you are able to find that and are unsure of how to interpret it, edit your question and include the relevant line(s) so we can try to help.