add ctrl+c protection for threads