Activity Monitor will allow you view how much energy your Mac using, but you can also use it to close unresponsive apps and processes, even if they're in a loop or not responding.
To quit an app or process:
In the Activity Monitor app on your Mac, under the Process Name list, select the app or process you want to quit. An unresponsive process is marked with (Not Responding).
Click the Force Quit button (X) in the upper-left corner of the Activity Monitor window.
Choose one of the following options:
Quit: This is the same as choosing File > Quit within an app. The process quits when it’s safe to do so. If quitting the process could cause data loss or interfere with another app, the process doesn’t quit.
Force Quit: The process quits immediately. If the process has files open, you may lose data. If the process is used by other apps or processes, those apps or processes could experience problems. To see if a process is used by another process, choose View > All Processes, Hierarchically.