Agents would have to be uninstalled using the uninstall script, see instructions here. Then they can be redeployed using the deployment script under the correct organization.
Uninstalled agents will show in an offline state and can be deleted by selecting the device, then selecting Delete under the action drop down at the bottom of the page.