make sure to unregister a protocol callback only if it's been registered