Having played around with this concept a bit... the danger here is that if you unmount the pnd at the end of all applications, if you have 2+ applications running using your libraries you may be pulling the carpet out from underneath them.
I had done some research into some kind of a lock counter or other way to determine how many apps are using the libraries/applications contained within, but this seems like a harder way to do it since it likely means some level of bash overhead, trust that nothing crashes, etc.
I've considered a few options around the issue.
1) Only allow one app at a time to use your libraries. It may be better to just drop a lock file someplace to at least signify that the libraries are in use by one app, and not let other apps use the libraries until the first app is done.
2) Just mount it and forget about unmounting. There are 8 loopback devices (I believe)... so as long as a user isn't consuming a lot of them then locking one up until next reboot may not be such a problem
3) Let the user control when to mount/unmount your libraries... though I see this as something that only benefits more advanced users. People that don't understand what is going on under the hood are going to hit strange/mysterious problems.
4) Oh, install the libraries onto SD and figure out how to 'permanently' add them to the path... this doesn't consume a loopback, but it will cause issues if somebody removes the SD card...
I'm sure that there is a good solution out there for this problem... I just haven't stumbled upon it yet