code: public void closeCurrentWindow() {
          String action = "Closing currently selected window";
          String expected = "Current window is closed";
          try {
              driver.close();
          } catch (Exception e) {
              reporter.fail(action, expected, "Current window was unable to be closed. " + e.getMessage());
              log.warn(e);
              return;
          }
          reporter.pass(action, expected, expected);
      }
docs: Close the currently selected window. After this window is closed, ensure
  that focus is shifted to the next window using switchToNewWindow or
  switchToParentWindow methods. This is an alternative to closeTab, as this
  works better for some systems and environments that others.