Add in support for detecting server closed connections in postgres

How about this implementation? Making use of your approach but still including it in the main repo, as much as I'd like to I'd like to contribute back to the main repo for things like this :)