Only commit transaction if active.