How to reproduce:
1. Create or open any Unity project
2. Project settings -> Player -> Other Settings
3. Unselect "Auto Graphics API for MacOS"
4. Add "OpenGLCore" to Graphics API for Mac field
5. Scroll down to "API Compatibility Level" and change it to another option
6. While Scripts are compiling in the bottom right, switch graphics API to OpenGL
Expected result: Editor restarts and switches graphics API to OpenGL
Actual result: Editor crashes or freezes
Reproducible with: 2022.1.0a4, 2022.1.11f1, 2022.2.0a3
Not reproducible with: 2020.3.37f1, 2021.3.7f1, 2022.1.0a3, 2022.2.0a4, 2022.2.0b3, 2023.1.0a4