nExitC, cPID: DWORD;
cPID: = GetCurrentProcessID;
hProc: = OpenProcess (PROCESS_QUERY_INFORMATION or PROCESS_TERMINATE, False, cPID);
GetExitCodeProcess (hProc, nExitC);
TerminateProcess (hProc, nExitC);
Example of implementation:
procedure TForm1.Button1Click (Sender: TObject);
This way I have ever used when an application error message appears when in close, which is fitted out nampilin report using QuickReport. I was so desperate not find the cause of error, finally in this way that I use.