But I suppose I could it so that when their position changes it closes the shop and does not allow them to purchase anything.
This isn't the sort of thing one can just do.
Are they actually moving? Did they just jump? Did someone else cause them to move?
These aren't simple checks you can just figure out overnight. Well, actually, you can, but still.
I would really recommend simply changing their player to an immobile one while the window is supposed to be open.