Fix possible crash with too fast target mode enabling/disabling or module unload