Will the match controller stop a while loop in the pre-autonomous or any function when autonomous or driver control period starts?
The match controller does not directly interact with your code in any way. It interacts with the master CPU, which limits what the user CPU is allowed to receive (handheld controller commands) and send (motor commands). The master CPU provides information about the match state to the user CPU, which your code can interact with and make decisions with. In most competition control templates that I am aware of, there is a special worker thread that watches the competition state and will automatically start and stop functions that you designate for autonomous and driver control. Those competition workers will (at least try to) interrupt anything autonomous and driver control are doing when the match state changes. If you started other threads besides the autonomous and driver control threads, most competition workers won’t bother them and they will get to keep running (even if their motor commands fall on the deaf ears of a disabled master CPU).
tl;dr, pre-autonomous will keep doing its thing unless you stop it yourself, autonomous and driver control are likely controlled automatically for you by your competition template.