Articles

This example shows, how to close application, which is losing focus and becoming deactivated. Use onDeactivate event of TApplication class.

procedure TForm1.CloseApp(Sender: TObject);
begin
  Close;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnDeactivate:=CloseApp;
end;