We're waiting for the native code to completely return back to JS, but the web workers (where it returns) are already terminated. I'm not sure exactly which functions need to return or get to a specific point before this is safe-- I haven't looked into it. I do know that there needs to be a few milliseconds of waiting before restarting works successfully (so I just picked 200).

Should I try to find a more robust solution for this?