public static void tearDownInVM() {
      // 1. Please do NOT add to this list. I'm trying to DELETE this list.
      // 2. Instead, please add to the after() of your test or your rule.

      disconnectFromDS();
      // keep alphabetized to detect duplicate lines
      CacheCreation.clearThreadLocals();
      CacheServerTestUtil.clearCacheReference();
      ClientProxyMembershipID.system = null;
      ClientServerTestCase.AUTO_LOAD_BALANCE = false;
      ClientStatsManager.cleanupForTests();
      DiskStoreObserver.setInstance(null);
      unregisterInstantiatorsInThisVM();
      DistributionMessageObserver.setInstance(null);
      InitialImageOperation.slowImageProcessing = 0;
      InternalClientMembership.unregisterAllListeners();
      LogWrapper.close();
      QueryObserverHolder.reset();
      QueryTestUtils.setCache(null);
      RegionTestCase.preSnapshotRegion = null;
      SocketCreator.resetHostNameCache();
      SocketCreator.resolve_dns = true;

      // clear system properties -- keep alphabetized
      System.clearProperty(GeodeGlossary.GEMFIRE_PREFIX + "log-level");
      System.clearProperty("jgroups.resolve_dns");
      System.clearProperty(Message.MAX_MESSAGE_SIZE_PROPERTY);

      if (InternalDistributedSystem.systemAttemptingReconnect != null) {
        InternalDistributedSystem.systemAttemptingReconnect.stopReconnecting();
      }

      IgnoredException.removeAllExpectedExceptions();
      SocketCreatorFactory.close();
      TypeRegistry.setPdxSerializer(null);
      TypeRegistry.init();
    }
Cleans up horrendous things like static state and non-default instances in Geode.

<p>
{@link DistributedRule#after()} invokes the same cleanup that this Rule does, but if you
defined {@code DistributedRule} as a {@code ClassRule} then you should declare TearDown
as a non-class {@code Rule} in your test:

<pre>
{@literal @}ClassRule
public static DistributedRule distributedRule = new DistributedRule();

{@literal @}Rule
public DistributedRule.TearDown tearDownRule = new DistributedRule.TearDown();

{@literal @}Test
public void shouldHaveFourDUnitVMsByDefault() {
  assertThat(getVMCount()).isEqualTo(4);
}
</pre>

<p>
Note: {@link CacheRule} handles its own cleanup of Cache and Regions.
geode-dunit/src/main/java/org/apache/geode/test/dunit/rules/DistributedRule.java