How to escape while control structure with implement of switch case

These comments are not correct:

break; // supposed that break the case 1 if other case is being pressed

break; just tells the code to go the the closing } of the section. It does not stop anything.

If you want to stop ongoing code, you need to create an Interrupt when a key is pressed, and use that interrupt to stop the ongoing code.