add close
fix UnicodeEncodeError