Desktop compilers
Your main form is destroyed when the application object destroys its components. This happens in FMX.Forms in the DoneApplication procedure.
procedure DoneApplication; begin if Screen <> nil then Screen.ActiveForm := nil; Application.DestroyComponents; <-- this is destroying your main form end;
And DoneApplication is called during shutdown as the proc output. This proc output is registered from TApplication.Run as follows:
{$IFNDEF ANDROID} AddExitProc(DoneApplication); {$ENDIF}
Class constructors are called from the unit initialization section that defines them. So, TGlobalClass.Create is called from uClassVar initialization. Destructor classes are called from the completion section of the same unit.
System shutdown is performed by the System block in _Halt0 . It performs all exit procedures before finalizing the module. Therefore, your form is destroyed before the destructor class is called.
Mobile compilers
Please note that DoneApplication simply not being called on Android.
{$IFNDEF ANDROID} AddExitProc(DoneApplication); {$ENDIF}
This means that the destruction of the main form is called from the final part of the block. Upon completion of each block, its completion sections are completed, as a result of which any global variables leave scope. In the end, there are no longer any links to your main form and therefore its destructor is executed.
As discussed above, class destructors are also called from module finalization. Since on Android, the class destructor is executed before the main form is destroyed, it is clear that uClassVar completed before the final link of the main form is released.
Now that makes sense, because uClassVar is the final unit in the initialization order and therefore the very first unit in the completion order. If you want uClassVar be completed later, you need to arrange it to initialize earlier. For example, by changing the uses clause of your .dpr file as follows:
uses uClassVar in 'uClassVar.pas', System.StartUpCopy, FMX.Forms, ufmMain in 'ufmMain.pas' {fmMain};
Now uClassVar is the first unit initialized, and therefore the last unit is complete.