server: wait for stream to close