The normal approach here would be three choices - Save? yes/no/cancel
Anyway for your approach try:
protected override void OnFormClosing(FormClosingEventArgs e)
{
base.OnFormClosing(e);
if (!e.Cancel) {
if (MessageBox.Show("Do you want to save changes?", "Close", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
SaveMyFile();
}
}
}