private void itmExit_Click(object sender, System.EventArgs e) { int mdiChildrenLenght = this.MdiChildren.Length; if (mdiChildrenLenght != 0) { for (int i = 0; i < mdiChildrenLenght; i++) { TextForm documentForm = (TextForm)ActiveMdiChild; documentForm.Close(); } } System.Windows.Forms.Application.Exit(); }