Create a global variable and name it something like "Level" (or "ShopReturnLevel" if "Level" is already taken).
Then, add a piece of code that says something like "If LayoutName = Level1... then set ShopReturnLevel to "1"."
Then, when you enter the shop, the Level will be stored. When you exit the shop, add a condition that says something like "If ShopReturnLevel = "1", then go to layout Level1."
Hope this helps!