Добавление элемента управления NotifyIcon в форму и обработчик события для FormClosing:
private void Form1_FormClosing(Object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = true;
this.Visible = false;
this.notifyIcon1.Visible = true;
}
}