I want to preform a check before my form is closed.

how can I do this when a user hits Alt + F4 or clicks the close button on my form?