Exhaust iterators before finishing transaction.
Use try-with-resources.