Exit playmode at runtime using code

HiiIIIiiii.

Is there a way that you can exit playmode using scripts?

Something along these lines.´:

if(GUI.Button...){
ExitPlaymode;
}

(Just an example.)

Thank you.

Seems like you can simple set EditorApplication.isPlaying = false/true to exit or enter playmode.