Remove thread raise

This removes our usages of `Thread#raise` since it is unsafe.  I also reworked a few things, and, along the way, found a couple bugs in our worker (e.g. where it could get stuck in a sleep loop but had been told to shutdown).

/cc @proby @benkirzhner @dlecocq