update pollset to reflect changed connection state before closing the socket; otherwise the pollset-remove can crash (at least with select-based poll, since fd is now -1)