bugfix: close batch when finish