Close library handle on exit