private void shutdownSessions() {
		// Copy the sessionThreads collection so the guarding lock on this
		// instance can be released before calling the Session.shutdown methods.
		// This is necessary to avoid a deadlock, because the terminating
		// session threads call back the sessionEnded function in this instance,
		// which locks this instance.
		List<Session> sessionsToBeClosed;
		synchronized (this) {
			sessionsToBeClosed = new ArrayList<>(sessionThreads);
		}
		for (final Session sessionThread : sessionsToBeClosed) {
			sessionThread.quit();
		}

		executorService.shutdown();
		try {
			executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
		} catch (final InterruptedException e) {
			LOGGER.warn("Interrupted waiting for termination of session threads", e);
			Thread.currentThread().interrupt();
		}
	}
Closes the serverSocket in an orderly way.
src/main/java/de/gessnerfl/fakesmtp/smtp/server/BaseSmtpServerRunnable.java