Calling .next() on a closed generator shouldn't throw

`next()` on a closed generator should just return `{value: undefined, done: true}` instead of throwing an exception.

Fixes #841