So, I'm having the same need, and I think i found a work around. The save button that submits my form has code and a rule as well that closes the form. So the form code runs first, then the rules are applied. So on click, the code runs, does some logic then submits it, then the rules run and closes the form.
The issue with this is that if there is an error on the submit, the form still closes and now i'm out of luck. What I did to remedy this was add a hidden field called closeForm, and set the condition of the rule in the save button to check if the closeForm field is not blank, then close the form. By default, this text box will be blank. I set a value in this text box after the submit completes successfully, so the form should only close upon a successful submittal.
I then handle the error and let the end user know. Works pretty darn well!