Another option is to send a wm_Close message to application / application.mainform
PostMessage(Application.Handle,wm_Close,0,0);
or
PostMessage(Application.MainForm.Handle,wm_Close,0,0);
This puts the close request in the message queue, existing messages already in the message queue will continue to be processed in the first place.
source
share