close entity manager when no more needed