PostgreSQL: add disconnect handling

Signed-off-by: swpd <swpdtz@gmail.com>