Add ability to detect and terminate hung workers. Fixes #333