Reorganize and test teardown callbacks.