Properly close resources in tests.