Fixed writes to stdin
Added terminate command