public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            var timer = new Timer() { Interval = 5000 };
            timer.Tick += new EventHandler(timer_Tick);
            timer.Start();
        }
        void timer_Tick(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }