Is this when a macro is triggering?
If it is related to Keyboard Maestro, select Help ➤ Interactive Help, Something unexpected is happening and see if that finds anything.
You can also look in the log files (Help ➤ Open Logs Folder). For some serious errors, Keyboard Maestro will been when it gets the error.