Handle clicking outside popovers correctly