[BUG] Terminal tool gets stuck after exit code

This is still a problem. Related fully described problem, with additional bugs: