Optimize: quit thread safely