Fix issue where threadFn is undefined.

The guardedThreadFn closed around threadFn, which is not defined in
the worker thread's scope.