Optionally keep stdin open

Some commands don't behave properly after `terminal.stdin.end()` is called. Make it optional.