=act #3389 Improve SSL closing sequence (backport)

* Port of this fix in Spray by @jrudolph from this pull request
https://github.com/spray/spray/pull/400