postgresql plugin: Unregister all writers on shutdown.
This will make sure that all pending transactions will be committed. Else, the
open transactions would be rolled back by the PostgreSQL backend when closing
the connection.
In order to do so, all database connections are now stored in a plugin-global
array (this will also make further changes possible). Also, a ref-count has
been added to the database object in order to support "deleting" an object
twice when having it in use by a connection doing queries and writes.