Doubt in OpenCv : Generating selfie training data using webcam

The link to code is - https://ide.codingblocks.com/s/239251 When I run my code on command prompt, it runs successfully. But, on pressing ‘q’ to stop the implementation of code, it does not stop. It keeps on running. Eventually, I have to close command prompt itself to stop the code. However, in video, sir’s code stops after pressing ‘q’ . Please tell why am I facing the error .