public void DisconnectThread([CanBeNull] string quitMsg) {
if (isConnected && quitMsg != null) {
ClearLocalQueue();
Send(IRCCommands.Quit(quitMsg));
} else {
isConnected = false;
}
IsReady = false;
AssignBotForInputParsing();
if (thread != null && thread.IsAlive) {
thread.Join(ThreadAbortTimeout);
if (thread.IsAlive) {
thread.Abort();
}
}
try {
if (reader != null) reader.Close();
} catch (ObjectDisposedException) {}
try {
if (writer != null) writer.Close();
} catch (ObjectDisposedException) {}
try {
if (client != null) client.Close();
} catch (ObjectDisposedException) {}
}