If you are running Jupyter Notebook on your local Mac/Windows device and you want to make sure that you did close the application gracefully, then here are a few ways to do it.
Option 1: Using the Menu Option
This is the the best and the ideal way to close a Notebook application.
Simply go to Menu: File and select Shut Down at the bottom.

You will get an alert asking if you really want o shutdown JupyterLab.

Once you click on "Shut Down" button, you will notice that the Command Line/Terminal that was running the Notebook server gets closed and so does the Browser tab.
Option 2: Using Command "jupyter notebook stop"
Open a new instance of your Terminal (CMD if on Windows) and run the below command.
jupyter notebook stop
You will notice that the Jupyter Notebook Server has stopped with logs as,
[I 2023-07-26 03:53:25.476 ServerApp] Shutting down on /api/shutdown request.
[I 2023-07-26 03:53:25.476 ServerApp] Shutting down 6 extensions
Option 3: The Quickest way - Control + C Twice
This is the quickest way to terminate a Notebook server, by pressing Control + C twice on the console.
^C[I 2023-07-26 03:55:33.181 ServerApp] interrupted
[I 2023-07-26 03:55:33.182 ServerApp] Serving notebooks from local directory: /Users/c2ctechtv
0 active kernels
Jupyter Server 2.7.0 is running at:
http://localhost:8888/tree?token=9dc1b9a830102024b31a2e78069f69469185eb19b9eb2223
http://127.0.0.1:8888/tree?token=9dc1b9a830102024b31a2e78069f69469185eb19b9eb2223
Shutdown this Jupyter server (y/[n])? y
[C 2023-07-26 03:55:34.759 ServerApp] Shutdown confirmed
[I 2023-07-26 03:55:34.761 ServerApp] Shutting down 6 extensions
When you press Control + C once you will see a message on console "Shutdown this Jupyter server (y/[n])" if you press Control + C again or type y will shutdown the server.

Facing issues? Have Questions? Post them here! I am happy to answer!
- Python: Convert Date to DateTime
- How to sort a List using Lambda in Python
- Python matplotlib segmentation fault: 11 macOS Big Sur
- What is Terminal Velocity and its Formula? How to calculate it programmatically?
- How to install Python 3.11 on Mac
- How to flatten a nested list in Python
- Python: Pandas Merge DataFrames on Index Example
- How to Run all Cells at Once Jupyter Notebook
- Python - Convert float to String
- How to add borders to tkinter label text
- How to Exit a Loop in Python Code
- [Python] Fix: ValueError: All arrays must be of the same length
- Sorting an array using Bubble Sort in Python Programming
- How to Unzip a file using Python
- Python: Merge DataFrames Pandas Outer Join Example
- Change label (text) color in tkinter
- Convert Float to String in Python
- Fix: fatal error: No such file or directory compilation terminated
- Python: Access index/counter of a for loop iteration
- Import Other Python Files Examples
- How to install Anaconda on Mac (M1/M2 Mac)
- Python Regular Expression to Find All Matches in List
- How to Read a binary File with Python
- How to disable warnings while Python file execution
- Know current Python Version
- Loading previous page using html button using JavaScript - JavaScript
- Remove ActionBar from Activity that extends appcompat-v7 - Android
- [Solution] IntelliJ: Cannot find declaration to go to, Nothing here, Java file outside of source root Errors - Java
- How to use SSH in Windows Terminal - Windows
- How to Go To /usr/local/bin on Mac Terminal? - MacOS
- Update SharePoint Online List Item using REST API, HTML, Spfx, Postman - SharePoint
- How to take screenshot on Android - Android
- Add a User as a Sudoer Using Ubuntu Linux Command Line Terminal - Ubuntu