To close Node Express server, we call close on the server instance.
For instance, we write
const server = app.listen(3000);
server.close((err) => {
  console.log("server closed");
  process.exit(err ? 1 : 0);
});
to call server.close to close the server.
We call it with a callback that’s called when the server is closed.
