public void closeProject(PluginFailureReason failureReason) {
    boolean previousValue = ModuleClasspathListener.ENABLED;
    ModuleClasspathListener.ENABLED = false;
    try {
      if (TypeSystemStarter.instance(_project).isStarted()) {
        try {
          if (TypeSystem.getCurrentModule() != null) {
            System.out.println("Cleaning type system, but current top module is not null!");
          }
          System.out.println("Stopping Type System " + TypeSystem.getExecutionEnvironment());
          stopTypeSystem();
        } catch (Throwable e) {
          reportStartupError(e);
        }
        try {
          uninitGosuPlugin();
        } catch (Throwable e) {
          reportStartupError(e);
        }

        try {
          for (ITypeSystemStartupContributor pluginListener : getStartupContributors()) {
            pluginListener.afterPluginShutdown(_project);
          }
        } catch (Exception e) {
          ExceptionUtil.showNonFatalError("Exception during Gosu plugin shutdown.", e);
        }
      }
    } finally {
      _failureReason = failureReason;
      ModuleClasspathListener.ENABLED = previousValue;
    }
  }
 private void stopTypeSystem() {
   TypeSystemStarter.instance(_project).stop(_project);
 }
 public boolean isStarted() {
   return TypeSystemStarter.instance(_project).isStarted();
 }