[v8.x] tls,http2: handle writes after SSL destroy more gracefully
Backport of https://github.com/nodejs/node/pull/18987 with only neighbouring-lines conflicts.
The test part was already backported in 80534746, and passes on v8.x even without the src/ changes; however, https://github.com/nodejs/node/issues/22923 seems to be a related issue that exists on v8.x currently, so backporting the rest probably makes sense.
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines