Stop background threads on user exit