Extendable object factories with OOP Fortran

You could try putting the relevant code in a final routine (see here) but I don’t believe the attempt would be successful, because to trigger it’s call, you need either an allocatable or an automatic instance of your class being finalized exiting a routine