Why the order of shutdown events is important

Try running this code:

PUBLIC xx

xx=CREATEOBJECT("MyClass")

quit && quit Foxpro

DEFINE CLASS MyClass as Custom

      PROCEDURE init

            CREATE CURSOR DummyCursor (name c(10)) && create a cursor

      PROCEDURE destroy

            SELECT DummyCursor && try to select the cursor just created

ENDDEFINE

What happens and why? On my machine, I get an error saying Alias 'DUMMYCURSOR' is not found.

You can see this behavior if you run the code in my prior post (Find which DLLs in your system are rebased) and then close VFP

One would expect that when the Quit occurs, the VFP process shuts down. This means releasing the public MyClass instance, which fires the destroy event.

The destroy event tries to find the cursor, but it has already been destroyed.

Apparently, probably for close to 15 years, the database engine shutdown code runs before the object manager shutdown.

Have you run into this issue before? Have you worked around it?