Ensure ResourceIterator is properly closed.
Merge pull request #1132 from jotomo/close-iterator

Ensure ResourceIterator is properly closed.