Deal with close window event

Finalize the form more normally.
Deal with form close button

Dispose the form object when the close button was clicked.