The fix in e0519ace is overly zealous, and can destroy a socket while there are still outstanding writes in progress. Closes GH-5688