fix a bug with teardown