Handle terminating signals.  Better, anyway.

Resolves #288.  Implementation doesn't make me very happy, but works reliably on our testcases.

Ever get the feeling that Linus is laughing watching us flail around?