I stuck with same issue, I ran this command
sudo apt install ng-common
and then this
ng --version
and it showed this screen what you mentioned « ---Mg: scratch (fundamental)----All----------------- »
I pressed alt+Enter, it showed a "quit" on bottom-left in my screen and then I pressed ctrl+z, and I got my terminal back with username and all (normal terminal)
frankly I didn't knew before, but it worked!!