implement CTRL-D handling