Fixed error: thread running after shutdown

Thread is now ended with a bool that is thread safe and gracefully shuts
down the program