I will just add that I still don’t recommend OnCloseQuery
for this purpose, for reasons explained in comment in Where to intercept closing application? - #3 by michalis I know it works in your project, but in general
-
OnCloseQuery
is a way to “ask for confirmation before closing form (e.g. to save some document)”, not “a place to do cleanup”. -
Stop
is a place to do cleanup, and if you wantStop
of your view to happen before somefinalization
, then useApplication.MainWindow.Container.View := nil
, as shown in this thread (point 3 above, which I understand the OP followed) or Where to intercept closing application? - #3 by michalis .