How does iMazing reboot/shutdown iPhone remotely? I was playing arround with iMazing and found out that it can reboot/shutdown my iPhone 6s without it being Jailbroken.

Does anyone know what commands it uses and how I could do this myself from my Mac?

When looking at the file contents, I found in the frameworks folder that is uses the frameworks DDNAToolKit.framework and DevMateKit.framework and in the MacOS folder, it contains an AppleScriptServer executable.

This functionality works via Wi-Fi and USB.
The protocol used for communicating between the iOS device and the host program (such as for example iTunes) actually specifically allows for rebooting and shutting down the device.

You can find an open source and free implementation of the protocol called libimobiledevice here.

The library is a collection of many different tools. You'll need the one called idevicediagnostics so that you can run commands like:

idevicediagnostics reboot

idevicediagnostics shutdown

If you want to do this from your own program, you can find the source code for the idevicediagnostics program (that uses the library) here:

https://github.com/libimobiledevice/libimobiledevice/blob/master/tools/idevicediagnostics.c