Unexpected restarts on your Mac can be a real nuisance. They can be caused by software installed on the Mac or by devices connected to it. If the problem persists and your Mac keeps restarting every time you try to start it up, it may eventually shut down. To prevent this from happening, follow the steps below to check your Mac's software and hardware. If nothing helps, you can try holding down the power button until your Mac shuts down.
This method should work even if some apps appear to be unresponsive. When you turn your Mac back on, you'll see a dialog box indicating that you left it because of a problem, and you'll be able to open the applications that were active when you turned it off. If the issue is due to software, there are some steps you can take to fix it. Check for software updates that might address the problem. If an application is causing the shutdown process to be interrupted, consider abandoning it in favor of an alternative if one exists.
You can also try restarting your Mac without running the problematic software first.