title: Aborting and resuming a Symfony Console command
body: <p>I have a <code>Symfony Console</code> command that iterates over a potentially big collection of items and does a task with each of them. Since the collection can be big, the command can take a long time to run (hours). Once the command finishes, it displays some statistics.</p>
  
  <p>I'd like to make it possible to abort the command in a nice way. Right now if I abort it (ie with ctrl+c in the CLI), there is no statistics summary and no way to output the parameters needed to resume the command. Another issue is that the command might be terminated in the middle of handling an item - it'd be better if it could only terminate in between handling items.</p>
  
  <p>So is there a way to tell a command to "abort nicely as soon as possible", or have the ctrl+c command be interpreted as such?</p>
  
  <p>I tried using the <code>ConsoleEvents::TERMINATE</code> event, though the handlers for this only get fired on command completion, not when I ctrl+c the thing. And I've not been able to find further info on making such resumable commands.</p>