Hello,
I guess it has to do with python working in one thread, or basically locking the process, and there is no time for editor to start when the end_play is triggered.
It works with a below snippet. Hope it helps.
import unreal
from threading import Timer
def hello():
print("hello, world")
unreal.EditorLevelLibrary.editor_end_play()
unreal.EditorLevelLibrary.editor_play_simulate()
t = Timer(5.0, hello)
t.start() # after 5 seconds, "hello, world" will be printed and editor will stop
Regards,
Alex.