fix race condition while unregistering plugins