#124 added a timeout to waitForAnyStream and change the way to close the server