Using a python "with" statement you don't need to unload/remove/delete the library, because when you leave the block of with, the resources are cleanly released regardless of the outcome of the code in the block. I suggest this postthis post to better understand the use of with.