[Console] fix and refactor exit code handling
Merge branch '2.1' into 2.2

* 2.1:
  [Console] fix and refactor exit code handling