Ensure that each instance of entity manager is properly closed.