Unload Revit Links

Just put this before you call Unload()

TransactionManager.Instance.ForceCloseTransaction()