Use threading event to determine whether we need to stop or not.

Signed-off-by: Kalman Olah <hello@kalmanolah.net>