First Check
Example Code
from nicegui import app, ui
def app_startup():
print('app startup')
def app_shutdown():
print('app shutdown')
app.on_startup(app_startup)
app.on_shutdown(app_shutdown)
@ui.page('/')
def index():
ui.button('destroy window', on_click=lambda: app.native.main_window.destroy())
ui.button('nicegui shutdown', on_click=lambda: app.shutdown())
ui.run(
title="Some app",
port=8502,
native=True,
reload=True,
window_size=(1920, 1200),
storage_secret='my secret'
)
Description
Very similar to #2107, but seems to be a different problem (or maybe the original fix is not enough), as the original problem is described to be windows only, but I'm on macOS now.
Specifically, the original issue itself is fixed: open the app, click either X or destroy window or nicegui shutdown, all three actions leads to a proper shutdown of the app even with reload=True. However, when you actually tries to use hot reload, the entire thing is again broken.
Full reproduction steps:
- Open the app
- Edit the file to add something irrelevant (like a comment), triggering an auto reload
- Press X or destroy window, the window closed but the app does not quit (the console is still in the app's process; in fact if you edit the file again the console will show a second hot reload message). Press nicegui shutdown still works properly.
Console output:
NiceGUI ready to go on http://127.0.0.1:8502
app startup
WARNING: WatchFiles detected changes in 'test.py'. Reloading...
app shutdown
NiceGUI ready to go on http://127.0.0.1:8502
app startup
<Press Ctrl-C>app shutdown
NiceGUI Version
3.8.0
Python Version
3.14.3
Browser
Other
Operating System
macOS
Additional Context
macOS Tahoe 26.3 (arm64) on an M2 Pro MacBook Pro
First Check
Example Code
Description
Very similar to #2107, but seems to be a different problem (or maybe the original fix is not enough), as the original problem is described to be windows only, but I'm on macOS now.
Specifically, the original issue itself is fixed: open the app, click either X or destroy window or nicegui shutdown, all three actions leads to a proper shutdown of the app even with
reload=True. However, when you actually tries to use hot reload, the entire thing is again broken.Full reproduction steps:
Console output:
NiceGUI Version
3.8.0
Python Version
3.14.3
Browser
Other
Operating System
macOS
Additional Context
macOS Tahoe 26.3 (arm64) on an M2 Pro MacBook Pro