backported https fix for ssl shutdown