When you close an entityManagerfactory instance and tries to open a new EntityManager with this factory, the JPA2 specification tells that an IllegalStateException should be thrown and it does not happen.
Description with examples here https://forum.hibernate.org/viewtopic.php?f=1&t=1015997