https://bugs.openldap.org/show_bug.cgi?id=10176
--- Comment #5 from Howard Chu hyc@openldap.org --- If you don't do a proper revert and restore the previous version of the code, then you'll have memory leaks when you dlclose() the library. If your program is exiting soon anyway, it won't matter, but if you dlopen/dlclose multiple times within a single run, it could become a problem.
Alternatively, since your program is exiting, you can just omit your own call to dlclose. Again, there's no point to it if the program is going away anyway.