Using AtomicBoolean instead of boolean for thread flags

Just being thread safe, trying to make sure the app can exit properly.