If i use the following
@PersistenceUnit(unitName="mongo")
EntityManagerFactory emf;
EntityManager em = emf.createEntityManager();
Will this annotation make sure that the EntityManagerFactory closes gracefully when application is destroyed?
Yes an injected EntityManagerFactory is automatically closed by the container.