When db is closed, make sure write transactions are closed

The catch here is that because we use thread-local storage in
dbm_lmdb.c, we can only close the write transaction of the current
thread. Nevertheless this should only happen when the process exits
(signal handler or program finished) so only one thread is supposed to
exist.
Merge pull request #1741 from jimis/lmdb_abort_txn_on_exit

When db is closed, make sure write transactions are closed
Special handling of signals for cf-key.

Handle SIGINT and SIGTERM to set gobal flag that makes the
ShowHost callback return false, thus causing ScanLastSeenQuality break
out of the while loop and return cleanly.

Fixes redmine #5957
Merge pull request #1742 from vohi/redmine/5957

Special handling of signals for cf-key.
Satisfy linker when building unit test.

This test is not testing anything right now, probably needs to
link in more code from libpromises once it does, but for now keep
it simple.