Immediately close all connections and stop workers.
976434
def close(self):
        """"""
        if not self.is_running:
            return

        self._state = CLOSED

        self.logger.debug('killing %d worker(s)', len(self._killables))
        self._killables.kill(block=False)

        self.logger.debug('closing %d connection(s)', len(self._connections))
        for conn in self._connections:
            conn.close_stream()

        self.on_close.send(self)
4546
void stopAll() {

		try {
			this.dmClient.closeConnection();
			stop();

		} catch( Throwable t ) {
			this.logger.warning( "An error occurred while closing the connection of the DM client." );
			Utils.logException( this.logger, new RuntimeException( t ));
		}
	}
697556
public void stop() {
		
		if (!this.running.compareAndSet(true, false)) {
			return;
		}

		// wake up all connections
		synchronized (this.connections) {
			for (final Connection conn : this.connections.values()) {
				conn.interrupt();
			}
		}

		// wait until all connections are closed
		while (!this.connections.isEmpty()) {
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
			}
		}
	}
1092096
def _close(self):
        """"""
        callback = self.__callback
        self.__callback = None
        try:
            if callback:
                callback(None, InterfaceError('connection closed'))
        finally:
            # Flush the job queue, don't call the callbacks associated with the remaining jobs
            # since they have already been called as error callback on connection closing
            self.__job_queue = []
            self.__alive = False
            self.__stream.close()
518337
def stop(self):
        """"""
        if self.interrupted:
            return
        for thread in self.worker_threads:
            thread.interrupted = True
        self.interrupted = True
335714
protected function shutdownWorkers()
    {
        $workers = Resque_Worker::all();

        foreach ($workers as $worker) {
            list($name, $pid, $queues) = explode(':', (string) $worker);
            posix_kill((int) $pid, SIGQUIT);
        }

        $this->output->writeln('<info>SIGQUIT sent to '.count($workers).' workers.</info>');
    }
821295
def terminate_all(self):
        """"""
        for worker in self._workers:
            worker.terminate()

        # for thread in self._threads:
        #     try:
        #         thread.terminate()
        #         thread.wait()
        #     except Exception:
        #         pass
        self._queue_workers = deque()
1233190
def close(self):
        
        keys = set(self._conns.keys())
        for key in keys:
            self.stop_socket(key)

        self._conns = {}
819218
public synchronized void stop() {
		// Mark us closed
		stopped = true;
		try {
			// Kick the server accept loop
			serverSocket.close();

			// acquire all semaphores so that we wait for all connections to finish before we report back as closed
			semaphore.acquireUninterruptibly(MAXIMUM_CONCURRENT_READERS);
		} catch (IOException e) {
			log.log(Level.SEVERE, "Caught exception: ", e);
		}
	}
543624
public void stopServer() {
        shouldRun = false;
        try {
            listener.close();
        } catch (IOException ex) {
            // Don't care
        }
        while (true) {
            synchronized (allWorkers) {
                if (allWorkers.isEmpty()) {
                    break;
                }
                for (Worker w : allWorkers) {
                    w.stopSocket();
                    w.interrupt();
                }
            }
        }

        try {
            listener.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
1192778
def terminate(self):
        """"""
        self.close()

        # Clearing the job queue
        try:
            while 1:
                self._workq.get_nowait()
        except queue.Empty:
            pass

        # Send one sentinel for each worker thread: each thread will die
        # eventually, leaving the next sentinel for the next thread
        for _ in self._workers:
            self._workq.put(SENTINEL)
850759
def killall(self, wait = None):
        
        with self.tasks.mutex:
            self.tasks.queue.clear()
        self.count_lock.acquire()
        self.kill(self.workers)
        self.count_lock.release()
        self.kill_event.wait(wait)
723346
def close_all_connections
      if @connections.empty?
        EM.stop_event_loop
      else
        server, connection = @connections.shift
        logger.debug "Beetle: closing connection to #{server}"
        connection.close { close_all_connections }
      end
    end
667629
def disconnect_all(self):
        ''''''
        with self._mutex:
            for conn in self.connections:
                self.object.disconnect(conn.id)
            self.reparse_connections()
1247756
async def stop(self):
        """"""
        await self._command_task.future_command(['_set_mode', 0, 0])  # Disable advertising
        await self._cleanup_old_connections()

        self._command_task.stop()
        self._stream.stop()
        self._serial_port.close()

        await super(BLED112Server, self).stop()
862724
public void shutdown ()
    {
        // close all of the connections
        for (Map.Entry<String, Mapping> entry : _keys.entrySet()) {
            entry.getValue().closeConnection(entry.getKey());
        }

        // clear out our mapping tables
        _keys.clear();
        _idents.clear();
    }
959129
public void stop() {
		isStarted = false;
		Iterator i = allConnections.iterator();
		while (i.hasNext()) {
			ConnectionWrapper connWrap = (ConnectionWrapper) i.next();
			try {
				connWrap.getConnection().close();
			} catch (SQLException e) {
				nrofErrors++;
				System.out.println(new LogEntry(e));
			}
		}

		allConnections.clear();
		availableConnections.clear();
		usedConnections.clear();
	}