Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=45282
Improve shutdown of NIO receiver so that sockets are closed cleanly.
This is essentially the patch that Filip suggested in the bug report with some additional refactoring by me.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1629776 13f79535-47bb-0310-9956-ffa450edef68