setDirty();
        SaveFileDialog saveFileDialog1 = new SaveFileDialog();
        saveFileDialog1.Title = "";
        saveFileDialog1.OverwritePrompt = true;
        var dialogResult = saveFileDialog1.ShowDialog();
        if (dialogResult == DialogResult.OK)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("CheckLoggin = {0}", chkLoggin.Checked).AppendLine();
            sb.AppendFormat("LogFilePath = {0}", txtFilePath.Text).AppendLine();
            sb.AppendFormat("NumberOfThreads = {0}", txtNumOfThreads.Text).AppendLine();

            File.WriteAllText(saveFileDialog1.FileName, sb.ToString());

            saveFileDialog1.Close();
        }
    }

Replace saveFileDialog1.Close(); with Application.Exit();

saveFileDialog1.Close(); terminates the application

problem solved thanx ChrisHunter

You're welcome.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.