'Set shutdown flag and wake threads up to close themselves'

def shutdown(self):

    with self.terminate.get_lock():
        self.terminate.value = True
    for _ in self.threads:
        self.queued_items.release()
    for t in self.threads:
        t.join()
