[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Forms' (#lcl)

# TApplication.Destroy

Destructor for the class instance.

## Declaration

Source position: forms.pp line 1596

`public destructor TApplication.Destroy; override;`

## Description

Destroy is the overridden destructor for the class instance.

Destroy ensures that the value AppDestroying is included in the Flags for the application, and signals the OnDestroy event handler (when assigned). Destroy calls the ProcessAsyncCallQueue method to process / handle queued asynchronous method calls pending for the application instance.

Hint display is cancelled and suppressed while the application is shutting down. The action component for the application is set to Nil to prevent execution of associated actions during shutdown.

Destroy frees resources allocated in the application instance, including the Icon and any Icon handles currently in use. Handlers added to application instance are also freed.

Destroy calls the inherited destructor, and discards any pending asynchronous calls not previously handled for the application instance. Exception handling is restored to the state on entry to the Create constructor. Finally, the Application class instance is set to Nil.

## Errors

Destroy calls RaiseGDBException to raise an exception if the current class instance is unassigned (contains Nil). Uses the exception message 'TApplication.Destroy Self=nil'.

Raises an EAssertFalied exception if the CustomApplication and Application variables do not contain the same TCustomApplication instance.