You have nothing to worry about. The bootloader will take care of this.
In general, shared libraries will be displayed in the address space of your process using memory mapping (all executed by the loader), and the OS keeps track of how many processes are still required for this shared library. The state data that is required separately for each process is usually processed by copying to write, so there is no danger that your crypto library may accidentally use a different process key :-) In short, do not worry.
Change You might be wondering what happens if the library function calls malloc() and is not cleared. Well, the library code becomes part of your process, so your process actually requests memory, so when your process terminates, the OS is cleaned up as usual.
source share