I did purge as suggested above with mixed results - see below.
I have tried to create a minimal example but I am in the middle of creating a "generic" storage system and, in order to save time, I created an example by extracting only the parts needed from this.
Scenario 2, below, applies to 2021, 2022, & 2023
I use Revit DB Explorer to check the status of the elements.
I have two scenario:
both start with a new, "empty" model.
scenario 1 - "purge first"
1. open model
2. run ExStoreTest
3. Write
4. Delete
5. Exit
6. check schemas: they are still in memory (expected)
7. purge unused: purge all
8. close & save model
9. open model
10. schemas do not exist
applies to 2021, 2022, & 2023
scenario 2 - "save first"
1. open model
2. run ExStoreTest
3. Write
4. Delete
5. Exit
6. check schemas: they are still in memory (expected)
7. close & save the model
8. open the model
9. check schemas: they ARE still in memory (not expected)
10. purge unused: no ex storage schemas listed
11. purge all anyway
12. close & save the model
13. open the model
14. check schemas: they ARE still in memory (not expected)
But of course, I cannot have the user manually, purge the schemas - especially, in my case, they may change multiple times during a session.