On OS X, sometimes the userscript exited before the QSocketNotifier was triggered. By doing a final read when cleaning up we make sure we don't miss anything. Fixes #1533.