handle situation when entityManager is closed in listener