Terminate worker threads before detaching main thread.

To avoid worker shutdown touching a detached main thread's heap, move
up the termination of worker threads in the shutdown sequence.

R=haraken,tzik
BUG=414380

Review URL: https://codereview.chromium.org/670683002

git-svn-id: svn://svn.chromium.org/blink/trunk@184071 bbb929c8-8fbe-4397-9dbb-9b2b20218538