Commit before closing the connection