Detect hard crashes of workers using a heartbeat mechanism.

Also fixes some issues in the rest of the code with detecting workers this way.