defer the channel close

This seems minor, but a bug that causes the iterator goroutine to panic
would lead to weird brokenness in callers if we didn't defer the channel
closed.