Invoking commit before close or cancel