[Issue 10101] New: Fix double file close when first TLS connection fails