Exec-form CMD so SIGTERM reaches your process
CMD node server.js runs under /bin/sh -c, so the shell is PID 1 and it does not forward signals. On docker stop the app never sees SIGTERM, sits through the ten second grace period, and gets killed mid-request.
CMD ["node", "server.js"]The JSON form execs the process directly, so your shutdown handler runs and in-flight requests finish. If the app spawns children and leaves zombies, add --init to docker run or init: true in Compose.
dockeroperations