Fix memory leaks: stream was not destroyed on timeout, error, close events