Revert "(#23124) Merge branch 'ticket/stable/23124-exit_codes_on_windows' into stable"

Reverting as this should have been targeted at 3.4.0 (on master).

This reverts commit 1f3ea533b06ccf5188f5dd371da722e7c84dc904, reversing
changes made to f4c7e8b7a67ae5ae60b0be12b97f12b6c3673291.