If the library's open count is 0 Exec will automatically unload it if needed (to free memory). Your expunge function would be called at that time.
I guess you could call your expunge function from your open routine though??? Your expunge routine would check the open count and only do anything if it's zero.
Also, you could manually expunge your library. Maybe add an option to do that in some program which uses the library? There's an example code fragment in the
RemLibrary() autodoc.