Fix worker termination handling

Fixes issue #102.