Fix crash when trying to clear the worker list.

Fixes #1023.