def unregister(self, cleanup_mode):
        """Unregisters a machine previously registered with
        :py:func:`IVirtualBox.register_machine`  and optionally do additional
        cleanup before the machine is unregistered.
        
        This method does not delete any files. It only changes the machine configuration and
        the list of registered machines in the VirtualBox object. To delete the files which
        belonged to the machine, including the XML file of the machine itself, call
        :py:func:`delete_config` , optionally with the array of IMedium objects which was returned
        from this method.
        
        How thoroughly this method cleans up the machine configuration before unregistering
        the machine depends on the @a cleanupMode argument.
        
        
        With "UnregisterOnly", the machine will only be unregistered, but no additional
        cleanup will be performed. The call will fail if the machine is in "Saved" state
        or has any snapshots or any media attached (see :py:class:`IMediumAttachment` ).
        It is the responsibility of the caller to delete all such configuration in this mode.
        In this mode, the API behaves like the former @c IVirtualBox::unregisterMachine() API
        which it replaces.
        With "DetachAllReturnNone", the call will succeed even if the machine is in "Saved"
        state or if it has snapshots or media attached. All media attached to the current machine
        state or in snapshots will be detached. No medium objects will be returned;
        all of the machine's media will remain open.
        With "DetachAllReturnHardDisksOnly", the call will behave like with "DetachAllReturnNone",
        except that all the hard disk medium objects which were detached from the machine will
        be returned as an array. This allows for quickly passing them to the :py:func:`delete_config` 
        API for closing and deletion.
        With "Full", the call will behave like with "DetachAllReturnHardDisksOnly", except
        that all media will be returned in the array, including removable media like DVDs and
        floppies. This might be useful if the user wants to inspect in detail which media were
        attached to the machine. Be careful when passing the media array to :py:func:`delete_config` 
        in that case because users will typically want to preserve ISO and RAW image files.
        
        
        A typical implementation will use "DetachAllReturnHardDisksOnly" and then pass the
        resulting IMedium array to :py:func:`delete_config` . This way, the machine is completely
        deleted with all its saved states and hard disk images, but images for removable
        drives (such as ISO and RAW files) will remain on disk.
        
        This API does not verify whether the media files returned in the array are still
        attached to other machines (i.e. shared between several machines). If such a shared
        image is passed to :py:func:`delete_config`  however, closing the image will fail there
        and the image will be silently skipped.
        
        This API may, however, move media from this machine's media registry to other media
        registries (see :py:class:`IMedium`  for details on media registries). For machines
        created with VirtualBox 4.0 or later, if media from this machine's media registry
        are also attached to another machine (shared attachments), each such medium will be
        moved to another machine's registry. This is because without this machine's media
        registry, the other machine cannot find its media any more and would become inaccessible.
        
        This API implicitly calls :py:func:`save_settings`  to save all current machine settings
        before unregistering it. It may also silently call :py:func:`save_settings`  on other machines
        if media are moved to other machines' media registries.
        
        After successful method invocation, the :py:class:`IMachineRegisteredEvent`  event
        is fired.
        
        The call will fail if the machine is currently locked (see :py:class:`ISession` ).
        
        
        If the given machine is inaccessible (see :py:func:`accessible` ), it
        will be unregistered and fully uninitialized right afterwards. As a result,
        the returned machine object will be unusable and an attempt to call
        **any** method will return the "Object not ready" error.

        in cleanup_mode of type :class:`CleanupMode`
            How to clean up after the machine has been unregistered.

        return media of type :class:`IMedium`
            List of media detached from the machine, depending on the @a cleanupMode parameter.

        raises :class:`VBoxErrorInvalidObjectState`
            Machine is currently locked for a session.
        
        """
        if not isinstance(cleanup_mode, CleanupMode):
            raise TypeError("cleanup_mode can only be an instance of type CleanupMode")
        media = self._call("unregister",
                     in_p=[cleanup_mode])
        media = [IMedium(a) for a in media]
        return media