Force termination of running service.
        Disconnect queues, end queue feeder threads.
        Wait for service process to clear, drop all references.
173658
def _terminate_service(self):
        """"""
        with self.__lock:
            if self._service:
                self._service.terminate()
            if self._pipe_commands:
                self._pipe_commands.close()
            if self._pipe_service:
                self._pipe_service.close()
            self._pipe_commands = None
            self._pipe_service = None
            self._service_class_name = None
            self._service_name = None
            if self._service_status != CommonService.SERVICE_STATUS_TEARDOWN:
                self.update_status(status_code=CommonService.SERVICE_STATUS_END)
            if self._service:
                self._service.join()  # must wait for process to be actually destroyed
            self._service = None
152750
public synchronized void stop() {
        Thread tmp=runner;
        runner=null;
        if(tmp != null) {
            tmp.interrupt();
            try {tmp.join(500);} catch(InterruptedException e) {}
        }

        // we may need to do multiple iterations as the iterator works on a copy and tasks might have been added just
        // after the iterator() call returned
        while(!queue.isEmpty())
            for(Task entry: queue) {
                entry.cancel(true);
                queue.remove(entry);
            }
        queue.clear();

        if(pool instanceof ThreadPoolExecutor && shut_down_pool) {
            ThreadPoolExecutor p=(ThreadPoolExecutor)pool;
            List<Runnable> remaining_tasks=p.shutdownNow();
            remaining_tasks.stream().filter(task -> task instanceof Future).forEach(task -> ((Future)task).cancel(true));
            p.getQueue().clear();
            try {
                p.awaitTermination(Global.THREADPOOL_SHUTDOWN_WAIT_TIME, TimeUnit.MILLISECONDS);
            }
            catch(InterruptedException e) {
            }
        }

        // clears the threads list (https://issues.jboss.org/browse/JGRP-1971)
        if(timer_thread_factory instanceof LazyThreadFactory)
            ((LazyThreadFactory)timer_thread_factory).destroy();
    }
45768
public void cancel() {

    this.stateLock.lock();

    try {

      if (this.state == RunnableProcessState.RUNNING) {
        this.process.destroy();
        if (!this.doneCond.await(DESTROY_WAIT_TIME, TimeUnit.MILLISECONDS)) {
          LOG.log(Level.FINE, "{0} milliseconds elapsed", DESTROY_WAIT_TIME);
        }
      }

      if (this.state == RunnableProcessState.RUNNING) {
        LOG.log(Level.WARNING, "The child process survived Process.destroy()");
        if (OSUtils.isUnix() || OSUtils.isWindows()) {
          LOG.log(Level.WARNING, "Attempting to kill the process via the kill command line");
          try {
            final long pid = readPID();
            OSUtils.kill(pid);
          } catch (final IOException | InterruptedException | NumberFormatException e) {
            LOG.log(Level.SEVERE, "Unable to kill the process.", e);
          }
        }
      }

    } catch (final InterruptedException ex) {
      LOG.log(Level.SEVERE,
          "Interrupted while waiting for the process \"{0}\" to complete. Exception: {1}",
          new Object[] {this.id, ex});
    } finally {
      this.stateLock.unlock();
    }
  }
631697
def shutdown(force=false)
      status(:closed)
      args = []
      args.push(:force) if force
      @logger.info("Pool is now shutting down #{force ? 'using force' : ''}")
      @queue.clear if force
      @queue.wait_empty
      while(t = @threads.pop) do
        t.stop(*args)
      end
      unless(force)
        flush
        @threads.each{|x|x.join}
      end
      nil
    end
974952
public void stop() {
		
		try {
			if (this.socket != null) {
				this.socket.close();
			}
		} catch (final IOException e1) {
			GPSdEndpoint.LOG.debug("Close forced: " + e1.getMessage());
		}
		
		this.listeners.clear();
		
		if (this.listenThread != null) {
			this.listenThread.halt();
		}
		
		this.listenThread = null;
	}
279214
private void stopServices() {
        // Stop services in reverse order of starting.
        m_logger.debug("Stopping all services");
        ListIterator<Service> iter = m_startedServices.listIterator(m_startedServices.size());
        while (iter.hasPrevious()) {
            Service service = iter.previous();
            m_logger.debug("Stopping service: " + service.getClass().getSimpleName());
            service.stop();
            iter.remove();
        }
        m_initializedServices.clear();
        m_storageServices.clear();
    }
403837
def stop(self):
        
        if not self.isThreadsRunning:
            raise ThreadManagerException("Broker threads are already stopped")
        self.isThreadsRunning = False
        for client in self.clients:
            client.stop()
743868
def stopService(self):
        
        Service.stopService(self)
        removeDestination(self)
        self._reactor.callFromThread(self._reactor.stop)
        return deferToThreadPool(
            self._mainReactor,
            self._mainReactor.getThreadPool(), self._thread.join)
472235
def shutdown(self, service_thread_map):
    """"""
    with self._services.lifecycle_lock:
      for service, service_thread in service_thread_map.items():
        self._logger.info('terminating pantsd service: {}'.format(service))
        service.terminate()
        service_thread.join(self.JOIN_TIMEOUT_SECONDS)
      self._logger.info('terminating pantsd')
      self._kill_switch.set()
426837
public final void end() {
    final Thread thread = threadRef;
    if (thread != null) {
      thread.interrupt();
      try {
        thread.join();
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
      }
    }
    this.threadRef = null;
  }
862751
@Override
	public void stop(final Runnable callback) {
		if (state.stop()){
			serviceThreadPool.execute(new Runnable(){
				@Override
				public void run() {
					try{
						doStop();
						state.finishStopping();
						callback.run();
					}catch(Exception e){
						state.failStopping();
						logger.warn("Failed to stop {}", this.getClass().getName(), e);
					}
				}
			});
		}
	}
1278926
def stop(self):
        """"""
        if self.running and self.num_workers:
            for worker in self.workers:
                self.queue.put(None)
            for worker in self.workers:
                worker.join()
            # Free up references held by workers
            del self.workers[:]
            self.queue.join()
        self.running = False
648086
public void stop() {
		if (serverThread != null) {
			try {
				//close and force IOException in server process
				server.close();
				//server thread will end as well
			} catch (IOException ioe) {
				System.out.println(new LogEntry(Level.CRITICAL, ioe.getMessage(), ioe));
			}
		}

		//close client connections as well
		for (Connection client : new HashSet<Connection>(connectedClients)) {
			if (!client.isClosed()) {
				client.close("server shut down...");
			}
		}
	}
190716
public void stop() {
    running = false;
    if (server != null) server.stop();
    if (aggregateDaemon != null) aggregateDaemon.interrupt();
  }
1215876
def stop(self):
        '''
        
        '''
        # clear queue up to first end loop command
        while(True):
            try:
                mtd, args, name = self._queue[0]
            except IndexError:
                break
            if(mtd == self._engine.endLoop):
                break
            self._queue.pop(0)
        self._driver.stop()
326924
public synchronized void stopThread()
	{
		if (isRunning())
		{
			if (log.isInfoEnabled())
				log.info("[Daemon] {stopThread} Requesting termination of thread " + thisThread.getName());

			this.running = false;

			synchronized (this)
			{
				this.notifyAll();
			}
		}
		else
		{
			throw new IllegalThreadStateException("Daemon must be started before it may be stopped.");
		}
	}
729494
def stop(self, wait=True):
        ''' 

        '''

        # TODO should probably close all connections and shut down all sessions here
        for context in self._applications.values():
            context.run_unload_hook()

        self._stats_job.stop()
        if self._mem_job is not None:
            self._mem_job.stop()
        self._cleanup_job.stop()
        if self._ping_job is not None:
            self._ping_job.stop()

        self._clients.clear()