Remove duplication of teardown logic