code: def close(self):
      
      with self.halting: # Avoid simultaneous "close" threads
  
        if not self.finished:  # Ignore all "close" calls, but the first,
          self.finished = True # and any call to play would raise ThreadError
  
          # Closes all playing AudioThread instances
          while True:
            with self.lock: # Ensure there's no other thread messing around
              try:
                thread = self._threads[0] # Needless to say: pop = deadlock
              except IndexError: # Empty list
                break # No more threads
  
            if not self.wait:
              thread.stop()
            thread.join()
  
          # Closes all recording RecStream instances
          while self._recordings:
            recst = self._recordings[-1]
            recst.stop()
            recst.take(inf) # Ensure it'll be closed
  
          # Finishes
          assert not self._pa._streams # No stream should survive
          self._pa.terminate()
docs: Destructor for this audio interface. Waits the threads to finish their
      streams, if desired.