Shutdown subprocess on exit

This handles cases like OOM errors that can leave an orphaned subprocess
running indefinitely.