ScriptRunner: Fix endless loop on EOF

Actually end the thread on script EOF instead of creating a tight loop that
spins on it endlessly.