you have to set the form's dialog result to OK or Cancel for it to close the form.