Added safer teardown method