diff --git a/docs/docs/reference/config.md b/docs/docs/reference/config.md
index 349f08e..b5a6f26 100644
--- a/docs/docs/reference/config.md
+++ b/docs/docs/reference/config.md
@@ -17,6 +17,8 @@ Puts the framework into development mode. \
Unlocks experimental features.
### *bool* custom_modules = *false*
Allows or disallows custom modules.
+### *bool* automatic_shutdown = *true*
+If `quit_safely` (and by extension `Core.cleanup`) should be called when pressing the X.
## Logger
### *CoreTypes.LoggerLevel* logger_level = *CoreTypes.LoggerLevel.INFO*
diff --git a/src/classes/config.gd b/src/classes/config.gd
index 132b8ae..fa428d6 100644
--- a/src/classes/config.gd
+++ b/src/classes/config.gd
@@ -17,6 +17,8 @@ class_name CoreConfiguration
@export var development: bool
## Allows or disallows custom modules.
@export var custom_modules: bool
+## If [method Core.quit_safely] (and by extension [method Core.cleanup]) should be called when pressing the X.
+@export var automatic_shutdown: bool
@export_category("Logger")
## The minimum log level you want to be displayed.
@export var logger_level: CoreTypes.LoggerLevel
@@ -46,6 +48,7 @@ func _init() -> void:
headless = false
development = false
custom_modules = false
+ automatic_shutdown = true
# Logger
logger_level = CoreTypes.LoggerLevel.INFO
diff --git a/src/core.gd b/src/core.gd
index dbab725..50cfa20 100644
--- a/src/core.gd
+++ b/src/core.gd
@@ -87,6 +87,7 @@ func _ready() -> void:
add_child(custom_modules_node)
loggeri = logger.get_instance(basepath.replace("res://", "") + "src/core.gd", self)
add_child(scheduler)
+ get_tree().auto_accept_quit = false
## Initializes all built-in modules during the preinitialization phase.[br]
## [b]Danger: [i]Don't call this.[/i][/b]
@@ -338,3 +339,9 @@ func quit_safely(exitcode: int = 0) -> void:
await get_tree().create_timer(0.25).timeout
await cleanup()
get_tree().quit(exitcode)
+
+func _notification(what) -> void:
+ match(what):
+ NOTIFICATION_WM_CLOSE_REQUEST:
+ if config.automatic_shutdown:
+ await quit_safely(0)