'Close the TarFile. In write-mode, two finishing zero blocks are
appended to the archive.'

def close(self):

    if self.closed:
        return
    self.closed = True
    try:
        if (self.mode in 'aw'):
            self.fileobj.write((NUL * (BLOCKSIZE * 2)))
            self.offset += (BLOCKSIZE * 2)
            (blocks, remainder) = divmod(self.offset, RECORDSIZE)
            if (remainder > 0):
                self.fileobj.write((NUL * (RECORDSIZE - remainder)))
    finally:
        if (not self._extfileobj):
            self.fileobj.close()
