<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _close(self):
 """ Append the xml fact list to the main document write file and cleanup. ``toxml`` should take care of encoding everything with UTF-8. """


        self.document.appendChild(self.fact_list)
        self.file.write(self.document.toxml(encoding='utf-8'))
        return super(XMLWriter, self)._close()