Safely quit queue thread