Fix Ctrl+D Crashes and Freezes (#296)

Cleaned version of https://github.com/p-e-w/finalterm/pull/306