I can confirm the editor closes immediately (which I find a bit odd as well).
To save your work, you could try adding to your script:
import unreal
unreal.EditorAssetLibrary.save_directory(assetPath)
unreal.EditorLevelLibrary.save_current_level() #in case you have changed things in the current level
assetPath is the path you want to save starting with ‘/Game/’ which is the root folder (Content) of your project
If you only want to save a specific path, just add it, e.g. ‘/Game/anotherFolder’’