Adding wait for connection to close.

Sometimes Play framework would close the stream for logging before.