code: def stop(self):
          
          self.prestop()
          if not self._graceful:
              self._graceful = True
          self.stream.stop_stream()
          self.audio.terminate()
          msg = 'Stopped'
          self.verbose_info(msg, log=False)
          # Log 'Stopped' anyway
          if self.log:
              self.logging.info(msg)
          if self.collect:
              if self._data:
                  print('Collected result:')
                  print('    min: %10d' % self._data['min'])
                  print('    max: %10d' % self._data['max'])
                  print('    avg: %10d' % int(self._data['avg']))
          self.poststop()
docs: Stop the stream and terminate PyAudio