GRIM/Lua: Don't close the stdin and stdout files when setting them. Fix #711
(cherry picked from commit 139319a0fbb6600118c697bbc3d0a860247acace)