<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def shutdown(self):
 """Wait for all threads to complete"""

        # cleanup
        self.started = False
        try:
            # nice way of doing things - let's wait until all items
            # in the queue are processed
            for t in self._threads:
                t.join()
        finally:
            # Emergency brake - if a KeyboardInterrupt is raised,
            # threads will finish processing current task and exit
            self.stopped = True