Close EntityManager after performing upgrade work - EUCA-9095

EUCA-9095