Further experimentation shows that commit 6051857fc is not sufficient when using (some versions of?) OpenSSL. The reason is obscure, but calling shutdown(socket, SD_SEND) improves matters.
Per testing by Andrew Dunstan and Alexander Lakhin. Back-patch as before.
ed52c3707b On Windows, also call shutdown() while closing the client socket.
src/backend/libpq/pqcomm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)