CA-127974: Added more checks to prevent XenCenter crash while closing [X...

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