When using QSslSocket::close() behind a proxy then a device error can occur as it seems to be closing the plain socket prematurely as there seems to be more bytes to be written. If disconnectFromHost() is used instead first then it works fine. An unencrypted connection also works fine.
With the example attached, the following can occur:
To reproduce, in mainwindow.cpp change the IP address to be the one used by the proxy, and then build the application. Click on the pushbutton to see the result.