Gracefully stop the bot

Is there any way to gracefully stop the bot? I want it to appear as offline as soon as it stops.
client.user!.setPresence({
  status: "invisible"
});
await client.destroy();
doesn't seem to work
Also, what's the reason that
setPresence
unlike basically any other similar method isn't async?
Was this page helpful?