Cleanups to the teardown function