To unroot, just go to /system/xbin. look for a file named su and delete it. Then uninstall whichever superuser app you have installed. (I don't know why you'd want to, though. The phone's being rooted doesn't change anything unless you run an app that asks for root [then it runs su first, then the app runs]. If you're running an app that doesn't request root access, it runs the same whether the phone is rooted or not.)
If you're looking to e able to run apps that won't run on a rooted phone, if you're rooted with Magisk, just hide root from that app. If you're system rooted, the superuser app should be able to hide root. If it actually looks for signs that the phone has been rooted, "unrooting" it won't do, you'll have to flash the factory ROM -
https://dl.google.com/dl/android/aosp/shamu-ngi77b-factory-5cd75e2a.zip is the file. (If you have a Nexus 6, you should have
Google | Factory Images for Nexus and Pixel Devices and
Google | Full OTA Images for Nexus and Pixel Devices bookmarked.)
(If the bootloader is already unlocked, you should also install
TWRP [if you haven't already], and make a data backup, then copy the backup and /sdcard to your Mac
before you flash the firmware.)