Add global cleanup and tests for it.