public synchronized void disconnect(String reason) throws IOException { log.info("Disconnecting"); for (IChannel c : channels) { c.part(); } log.info("Closing server connection"); sender.write(irc.quit(reason)); sender.flush(); sender.close(); receiver.close(); if (!connection.isClosed()) { connection.close(); } }