You can use the below script:

==================================

Get-SPDatabase $syncdb=Get-SPDatabase -Id

$syncdb.Unprovision()
$syncdb.Status='Offline'
Get-SPServiceApplication
$upa=Get-SPServiceApplication - Id
$upa.ResetSynchronizationMachine()
$upa.ResetSynchronizationDatabase()
$syncdb.Provision()