This is how I typically handle it in the form_closing event. Not sure how you would handle it in dispose method since you won't know if user is closing or if system is logging off etc.
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
if (MessageBox.Show("Are You Sure You Want To Exit", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.No)
{
e.Cancel = true;
}
}
else
{
if (handler != null) handler.Stop();
}
}