Control messages can be sent in the middle of a fragmented message.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1453435 13f79535-47bb-0310-9956-ffa450edef68
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54612
Check if socket is closed before trying to write a message to it.
Also, flush any partial buffered data before closing the socket.

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