Fixed small bug on closing library