
Ctrl-D is mapped as a delete key in readline. When some input is on the line, Ctrl-D behaves like 'Delete' key. When the line is empty, EOF is generated. We quit on this EOF. It is the same behaviour many other interactive programs exhibit, like bash, python, irb, etc. Users can also quit unconditionally with Ctrl-\ that traditionally generates SIGQUIT.