public void Stop() { Lock(this) //prevent any other code interupting { listener.Close(); listener.Dispose(); listener = null; Running = false; } }