public void windowClosed(WindowEvent e) {
         
         AppInstance closingApp = getApplication(e.getWindow());
         
         if(closingApp == null) return;
        
         WeakVector windows = closingApp.getWindows();
         Iterator it = windows.iterator();
         boolean openWindows = false;
         while(it.hasNext()) {
            Window w = (Window)it.next();
            if(w != null && w.isDisplayable()) openWindows = true;
         }
         
         //If no open windows check active threads and exit VM if we should
         if(openWindows == false) {
            if(Boot.isHeadless() == false && Boot.isLaunchingExternal()) {
               Boot.endSession(true);
               return;
            }
         }
      }