Port fix from CoffeeScript by bobbydavid to properly close the history file fd when the REPL exits rather than when the node process is exited.