How can I remove a linked library with Python? Load and add linked object

I'm working on an add-on. The purpose is to link and un-link groups from another blend file. Thanks to stack exchange and the Blender documentation this works pretty well.

This means I can load a library and import a group from it. 

with bpy.data.libraries.load(path, link=True) as (sourceData, targetData):
    targetData.groups = sourceData.groups


Then I search the library and extract the group to create an instance of the group:

instance = bpy.data.objects.new(name, None)
instance.dupli_type = 'GROUP'
instance.dupli_group = group
context.scene.objects.link(instance)


The result is a dupli-group object that links in the other blend file. (the link is persistent and will survive a reload .. that is what I want).



Unlink/Remove/Delete

My idea is to do the opposite. If the user does not want this link anymore, I would like to get rid of 


the instance
the group
the linked library


This works pretty nicely too for this instance:

context.scene.objects.unlink(instance)
bpy.data.objects.remove(instance)


and the group:

group.user_clear()
bpy.data.groups.remove(group)


I saw (in the outliner/Blendfile)there is still a user to the library. I guess it is the group object. So I removed that too:

for object in  library.users_id:
    for object in  library.users_id:
        object.user_clear()
        bpy.data.objects.remove(object)


Now the outline shows me the library without any user ... but



How can I unload/remove/delete the library without reloading the blend file?

It seems there is no API call to do that. bpy.data.libraries.remove() does not exist. There is a load but no unload. 

Saving/Loading the file removes the library. But this is far away from any comfort. 


  Reloading the blend file destroys the current context. E.g. undo would not be possible anymore. It also involves unnecessary file operations, that leads to another cycle in the backup files. Beside of that it simply feels incorrect to use such a workaround (Imagine you need to restart your PC each time you delete a file)


I found this one: Q: Proper way to remove unused linked Group data-blocks but this does not answer my question as I want to get rid of the library not just the group.

Do I miss something?

Thank you
Monster
Quite an old thread, but it seems there is finally a solution available.
Newer versions of Blender provide the batch_remove method in the bpy.types.BlendData type.
So you can call:
bpy.data.batch_remove(ids=(my_library,))

my_library is a bpy.types.Library object in this case and no string/name.
Keep in mind that to this date, the documentation states, that this method is considered experimental, but as long as you don't deal with blend file critical data blocks like scenes, it seems you should be fine.