static void Exit_Select(object sender, EventArgs e) { ntfy.Visible = false; ntfy.Dispose(); STOP = true; //let the other thread exit Thread.Sleep(pollRate + 1000); write.Close(); Application.Exit(); System.Environment.Exit(0); }