graceful stopping, better threads, cleanup