According to the messages returned by First Aid, it seems that the file system is corrupted, and First Aid failed to repair the disk error. Such a hard drive failure could lead to Mac keeps shutting down.
Therefore, if you fix the drive issue file system check exit code is 8, it may solve the problem Mac keeps shutting down, you can run First Aid multiple times in macOS Recovery mode and use the FSCK command in Single User Mode.
Perhaps, the Mac still shuts down randomly, then, you can try the following solutions:
- Make sure your Mac is powered up properly to work correctly
- perform a complete shutdown
- Restart Mac in Safe Mode
- Reset SMC and NVRAM
- Reinstall macOS
- Uninstall the recently installed app