Implements TCP half-duplex close. It is needed for Go and may be useful too.