The firebird client libraries libfbembed.so and libfbclient.so install exit handlers via atexit(). If the libraries are used by a module which is dlopen()ed at runtime (e.g. by a database abstraction layer which loads database drivers as modules, see http://libdbi.sourceforge.net),
the pointers to the installed handlers dangle as soon as the modules are unloaded via dlclose(). This causes the program to crash on exit on all platforms which do not use obscure workarounds to prevent this.
Some operating systems (most notably Solaris, recent Linux versions) do implement obscure workarounds, so you won't see a problem here. Other operating systems (FreeBSD) no longer support these obscure workarounds as there are apparently more appropriate ways to clean up libraries upon closing than installing exit handlers, see e.g. this thread: http://lists.freebsd.org/pipermail/freebsd-hackers/2007-December/022763.html
which includes a simple testcase to reproduce the problem.
I kindly ask to avoid using atexit() in the client libraries in order to allow programmers to access the firebird client libraries from dlopen()ed modules in a portable and robust way.