code: def _close_thread(self, thread, thread_name):
          
          if thread is not None and thread.isAlive():
              self.logger.debug("Waiting for {} thread to close".format(thread_name))
              thread.join(timeout=self.settings['DAEMON_THREAD_JOIN_TIMEOUT'])
              if thread.isAlive():
                  self.logger.warn("{} daemon thread unable to be shutdown"
                                   " within timeout".format(thread_name))
docs: Closes daemon threads
  
          @param thread: the thread to close
          @param thread_name: a human readable name of the thread