AC-7188. Fix an invalid read.

Fix an invalid read in torque that comes about when the main thread exits before the other threads spawned, resulting in the other threads attempting to access global memory that has been freed.