Not coming out from function in a case to another case

We can guess that you wrote all the code yourself and you tested step by step as you wrote it. If you don't want to show the code so someone else can duplicate the error, then I guess you are a big girl and need to spend more time debugging.
Paul