public void logout() throws VMWareException {

        logger.info("Closing session");

        try {
            if (serviceInstance != null) {
                serviceInstance.getSessionManager().logout();
                serviceInstance = null;
            }
        } catch (PlatformConfigFault f) {
            throw new VMWareException(f);
        } catch (com.vmware.vim25.NotAuthenticated authExc) {
            logger.info("Problem: NotAuthenticated, setting instance to NULL");
            serviceInstance = null;
        } catch (RemoteException exc) {
            throw new VMWareException(exc);
        } catch (Exception exc) {
            throw new VMWareException(exc);
        }
    }