I\'ve actually written a tracelistener component that logs to a networkstream. The code for that is here:
using Newtonsoft.Json.Linq; using System; using System.
Apparently ProcessExit event works. :(
AppDomain.CurrentDomain.ProcessExit += (s, e) => { SendCommand("QUIT", "closing connection"); _reader.ReadLine(); //TODO : verify the response code received client.Close(); };