thermal: core: Fix use-after-free in thermal_zone_device_unregister()