socket: allow upgrades if the socket is still in closing state (courtesy of @3rd-Eden)

This ensures that any buffered data still to be flushed, can be sent to the client.
After flushing the data, if the `readyState` was set to `'closing'`, this will close the newly created transport and the connection.