Fix Ctrl+D Crashes and Freezes (#296)

Cleaned version of https://github.com/p-e-w/finalterm/pull/306
Also note the possibility of multiple child processes terminating simultaneously with only one `SIGCHLD` being sent as explained in the comment in the original code, though I haven't gotten this to work either.