Windows form how to run lines of code on exit c# code example Example: c# program exit System.Windows.Forms.Application.ExitThread( )