[Code] procedure ExitProcess(exitCode:integer); external 'ExitProcess@kernel32.dll stdcall'; procedure SomeEventHere(); begin if someerror then begin ExitProcess(9); //Your custom exit code end; end;