def finish(self):
        """Finalize the MAR file.

        The MAR header, index and signatures need to be updated once we've
        finished adding all the files.
        """
        # Update the last_offset in the mar header
        self.write_header()
        # Write out the index of contents
        self.write_index()

        if not self.use_old_format:
            # Refresh the signature
            sigs = self.calculate_signatures()
            self.write_signatures(sigs)