Make sure libraries get closed after use