The to-statements implementation of RepositoryConnection returns a lazy sequence backed by an internal org.eclipse.rdf4j.repository.RepositoryResult. This class contains a close which should be called when the internal sequence has been fully realised or in case of an error.