我可以想到三种退出IEx Shell的方法:

  1. The mentioned <ctrl-c> hit twice or once followed by q and then <enter>,
  2. <ctrl-g> and then q + <enter>,
  3. and finally System.halt,

but there is a difference between System.halt and the others.

Namely that System.halt "halts the Erlang runtime" and the others just "quit the shell".

When you have only one shell session running or the session is not attached to a separate runtime then both ways will produce the same result. But if you have a session connected to a separate runtime e.g. via iex --remsh (remote shell) then running System.halt in it will halt the runtime and so make both shell processes / runtimes terminate. Just quitting a shell (via method 1. or 2.) will not stop the runtime it is connected to.

Conclusion: if you connect with your shell to other runtimes then know that System.halt will halt the runtime you have connected to. If you do not want to do it use <ctrl-c>.

UPDATE: Recently I have also found out about <ctrl-\>. You can read more about it in this article:

我不知道您可以通过发送Ctrl-退出外壳。   外壳将立即退出。据我所知,它具有相同的   效果就像在Break命令中中止外壳一样,不影响   远程节点,它也可以在iex外部运行(例如,您可以   用于终止测试)。