This happened many times.
While the SSH active, I'm so tired and just close the terminal without
Is it dangerous to doing like that?
Not at all. When the terminal process exits, the client processes within will also die, and when this happens, the connection to the remote server will be closed by the operating system. The server will see the connection close, and terminate the processes on the server.
However, it is possible that you might end up with lingering processes on the server if they were backgrounded and ignore certain signals.
When we closes the terminal directly, It generates a SIGHUP signal. This signal kills all the tasks/processes under the terminal automatically/instantly. So no problem occurring.
This may not be true. If bash is running a loop, it can ignore SIGHUP and continue the session. I'm currently trying to work out why this happens.
Also, the shutdown process is noted very well here but apparently Systemd has changed some behaviours.