Closing the main form will/should cause the app to close. In the Cancel button event handler in your form, do this:
this.Close();
Or, you can set
this.DialogResult
to
false
. This will cause the form to close.
Either way, if you're also handling the
Close
event, make sure your code is processing according to which button was used to close the form.