Ensure proper teardown.