Connection is set to null just when quit message is written