A prediction may be aborted by the user while your generator is still running. In such cases, you should handle the abort gracefully by handling the ctl.abortSignal.
You can learn more about AbortSignal in the MDN documentation.
This page's source is available on GitHub