Some of these steps might not be necessary. It might could be accomplished with a kill -9 on postgres. I tried running Postgres on Windows, and force killing it, but then the client always knew the connection was down.
When this occurs "in the wild", it is usually related to a timeout, so the fix that was checked in recently for setting tcpKeepAlive might be a workaround.