the ms remote deskop app is not a good macos citizen. it stops restarts and asks users whether to quit - this is silly and not mac-like. since the remote session is unaffected there is no reason for such an exclusive behavior.
DO NOT STOP MACOS RESTART COMMANDS. be a good mac app citizen instead and just terminate when asked to by the os.