CA-127974: Added more checks to prevent XenCenter crash while closing [XOP-521]

Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>