Close stream with error if 'to' not specified