using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; namespace ConsoleApplication2 { class Program { [DllImport("kernel32.dll")] static extern IntPtr GetCurrentProcess(); [DllImport("kernel32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] static extern bool TerminateProcess(IntPtr hProcess, uint uExitCode); static void Main(string[] args) { IntPtr handle; uint excode = 2; handle = GetCurrentProcess(); TerminateProcess(handle, excode); Console.WriteLine("This code will not be executed!"); } } }