Command line export doesn't exit if there is a build error

Tested versions
Reproducible in

v4.3.dev6.mono.official [89850d553]

hangs at the very end

v4.3.beta1.mono.official [a4f2ea91a]

hangs after "ERROR: Attempting to parent and popup a dialog that already has a parent."

System information
Godot v4.3.dev6.mono - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 6GB (NVIDIA; <IP_ADDRESS>12) - Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz (4 Threads)
Issue description
If I try to export the project from command line but there is build error, either GDScript error or C# error, Godot executable doesn't exit. I need to press Ctrl-C to exit.
A build error seems to cause this problem every time. But I also noticed that sometimes even working build doesn't exit cleanly if I ran the export command from Window's bat-file. However, I don't know to reprocude that.
I also wonder, if it would be better to instantly quit the exporting process, if the build fails. Now the process continues with the savepack.
This is a somewhat shortened and anonymized output:
λ "C:\godot\Godot_v4.3-dev6_mono_win64\Godot_v4.3-dev6_mono_win64_console.exe" --verbose --headless --no-window --export-release "Windows Desktop"
Godot Engine v4.3.dev6.mono.official.89850d553 - https://godotengine.org
TextServer: Added interface "Dummy"
TextServer: Added interface "ICU / HarfBuzz / Graphite (Built-in)"
Using "default" pen tablet driver...

TextServer: Primary interface set to: "ICU / HarfBuzz / Graphite (Built-in)".
.NET: Initializing module...
Found hostfxr: C:\Program Files\dotnet\host/fxr/8.0.4/hostfxr.dll
.NET: hostfxr initialized
.NET: GodotPlugins initialized
CORE API HASH:<PHONE_NUMBER>
EDITOR API HASH: 130872444
EditorSettings: Load OK!
EditorTheme: Generating new theme for the config '66886095'.
EditorTheme: Generating new icons.
EditorTheme: Generating new fonts.
EditorTheme: Generating new styles.
Found .NET Sdk version '8.0.204': C:\Program Files\dotnet\sdk\8.0.204
Loaded system CA certificates
Failed to bind socket. Error: 3
Failed to bind socket.  Log file: ...
dotnet_publish_project: end
ERROR: Failed to export project: Failed to build project.
   at: void GodotTools.Export.ExportPlugin._ExportBegin(System.String[], bool, string, uint) (/root/godot/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs:123)
System.InvalidOperationException: Failed to build project.
   at GodotTools.Export.ExportPlugin._ExportBeginImpl(String[] features, Boolean isDebug, String path, Int64 flags) in /root/godot/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs:line 255
   at GodotTools.Export.ExportPlugin._ExportBegin(String[] features, Boolean isDebug, String path, UInt32 flags) in /root/godot/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs:line 123
savepack: begin: Packing steps: 102
...
savepack: end
ERROR: Attempting to parent and popup a dialog that already has a parent.
   at: (scene/main/window.cpp:1838)
EditorSettings: Save OK!
Unloading: Disposing tracked instances...
Unloading: Finished disposing tracked instances.
XR: Clearing primary interface
XR: Removed interface "Native mobile"
XR: Removed interface "OpenXR"
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object/object.cpp:2314)
Leaked instance: Image:9223373671391885761 - Resource path:
Leaked instance: Image:9223373672683731395 - Resource path:
Hint: Leaked instances typically happen when nodes are removed from the scene tree (with `remove_child()`) but not freed (with `free()` or `queue_free()`).
Orphan StringName: _setup_local_to_scene (static: 0, total: 2)
Orphan StringName: EditorFileDialog (static: 1, total: 7)
Orphan StringName: AudioStream (static: 0, total: 1)
Orphan StringName: ItemList (static: 1, total: 9)
Orphan StringName: TabBar (static: 1, total: 9)
Orphan StringName: FileDialog (static: 6, total: 12)
Orphan StringName: AudioStreamRandomizer (static: 1, total: 5)
Orphan StringName: export_presets_runnable_updated (static: 0, total: 1)
Orphan StringName: OptionButton (static: 2, total: 12)
Orphan StringName: Node (static: 12, total: 13)
Orphan StringName: export_presets_updated (static: 0, total: 1)
Orphan StringName: Texture2D (static: 0, total: 5)
Orphan StringName: PopupMenu (static: 1, total: 15)
StringName: 13 unclaimed string names at exit.
^C

This is what Windows task manager displays while building:

and finally after the error message:

After pressing Ctrl-C .NET Host and Godot Engine (Console) disappear from Task manager.
Steps to reproduce

Add some build breaking error to the project code.
Run "Godot_v4.3-beta1_mono_win64\Godot_v4.3-beta1_mono_win64_console.exe" --verbose --headless --no-window --export-release "Windows Desktop"

Minimal reproduction project (MRP)
N/A

I've noticed something similar, however when I look at Task Manager the process actually did quit.  And when I simply press RETURN a few times on the keyboard, an empty prompt appears in the text (see the top few lines of the following screenshot)

Is this the same in your case?
Steps to reproduce:

use godot 4.3.dev on Windows in Powershell
cd to a folder where a godot project does not exist, like ~/Desktop
run the command godot --headless -v --export-release "anything" anything.exe
appears to not exit, but does exit

Also this causes a crash and that crash should be fixed too.

Does this crash only happen in 4.3 versions, or also 4.2?

This particular terminal issue doesn't even need a crash for me and is reproducible with 4.2.2 stable
Repro Steps:

godot --version
terminal appears to hang
type echo $?
the value echo command prints True because godot --version exited successfully

https://github.com/godotengine/godot/assets/145938/1c27935b-7e90-4324-b2c1-3df1f4564203

It's not limited to Terminal, Command Prompt (cmd.exe) also shows this issue.

open cmd.exe
godot --version
looks like it's hung
echo %errorlevel%
echo executes and returns 0 (success)

Are you running console.exe executable? If not, this is expected, it's GUI executable and it doesn't own the console, so shell have no idea it should redraw the prompt.

Using the .console.exe executable solves this issue for me, thanks @bruvzg !

Still hangs with v4.3.beta1.mono.official [a4f2ea91a], but now it hangs immediately after "ERROR: Attempting to parent and popup a dialog that already has a parent.". I made some updates to the issues description.

I also have this issue using Godot 4.2.2 stable and executing the *.console.exe binary like so
Godot_v4.2.2-stable_win64_console.exe --headless --path <path> --export-release <preset> output.exe