That probably depends what you mean with “leave the terminal”. If you mean “closing it” then yes. That is expected. Because with the terminal also all its processes get closed and so also n8n. If you mean “leave it open and simply do something else” then “no”, n8n should then keep on running.
If you want to “detach” n8n from the terminal you can add the option -d and remove the interactive flags. n8n will then keep on running even if you close the terminal. So something like this:
Not sure what you mean with “n8n finishes the editor”. If you close only the editor in the web-browser then everything will still work fine. If you however close n8n itself (like what you did with closing the terminal) then nothing will work anymore.
So, maybe a little context around how executables run under Linux would help make this clearer because process execution can be very confusing.
When a program is run under Linux, this is called a process. You can think of it like a machine that someone does something to get it to perform a function. These processes (like the machine) need a user (or another process which was initially started by a user) to start them.
When a user is logged into the system interactively (usually via a GUI, command line, or SSH), the process will generally continue to run until one of four things happens:
The process finishes what it was supposed to do
The process experiences an error and crashes
The user kills the process
The session closes either by the user or the system
At this point, the process is no longer running and what it was doing has stopped. So, in the case of n8n, when the docker process is no longer running because the session has closed, n8n is no longer available.
Earlier, I mentioned that the process will generally run until one of four things happens. There is an exception to this and it occurs when an application is run in the background or detached from a user session. This way, when the session is closed, the application will still be available, assuming that it either has a different way of interacting with a user (i.e. the n8n web interface) or does not require user interaction (e.g. an automated backup program). These type of processes are sometimes referred to as services or daemons.
There are several ways to keep these processes running in the background after you have closed the terminal. You may wish to give this article a read or my earlier post about running n8n as a service using PM2.
Hopefully that helps with a bit of understanding what is going on behind the scenes.