class ElasticAPM::Transport::Base

def stop_workers

rubocop:disable Metrics/MethodLength
def stop_workers
  debug '%s: Stopping workers', pid_str
  send_stop_messages
  @worker_mutex.synchronize do
    workers.each do |thread|
      next if thread.nil?
      next if thread.join(WORKER_JOIN_TIMEOUT)
      debug(
        '%s: Worker did not stop in %ds, killing...',
        pid_str, WORKER_JOIN_TIMEOUT
      )
      thread.kill
    end
    @workers.clear
  end
end