Add a flag to threads that indicates that it wants to stop execution ASAP.