Adding a second round of termination detection after shutdown function were executed. That should take care of the problem reported by #1264: Error "assertion '!m_fun' failed" randomly occurs when using TCP