Closing form and transaction

If I am using transactions on a form/dialog what is the best way to deal with the close window button and commiting/rolling back the transaction.

You can attach a method to the onHide event of that form. If that method returns false, the dialog is not closed. That allows you to ask the user what to do.