Close handler on remove. Add missing test.