Add proper library close support

And a command to call the close library function.

Also changed the return value of the open library functions to a
pointer to the library struct. This makes more sense as the library
struct will be necessary for modifying the libraries themselves.

Signed-off-by: Alex Waterman <imNotListening@gmail.com>