Close Main Form

Do not pass your main form as argument to Application.Run:

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

MainForm frmMain = new MainForm();
frmMain.Show();

Application.Run();

Thus you will be able to close it when showing another form:

private void btnSubmit_Click(object sender, EventArgs e)
{
     frmData QS = new frmData();
     QS.Show();
     this.Close();
}

To close application you should use

Application.Exit();

Hide the first form.

private void btnSubmit_Click(object sender, EventArgs e)
{
     frmData QS = new frmData();
     QS.Show();
     this.Hide();
}

private void frmData_FormClosed(object sender, FormClosedEventArgs e)
{
    Application.Exit();
}

Tags:

C#

Winforms