Another Variant for detecting if a connection is closed

I seem to get "unknown error" on connections where the postgresql
database was forcefully restarted, which is not detected as a
disconnect.