It determines when to close the application if a form is closed (if your application is not attached to a specific form).
private void MyForm_FormClosed(object sender, FormClosedEventArgs e)
{
if (Application.OpenForms.Count == 0) Application.Exit();
}