How long they stay on the shelves - that can depend. For subjects in which there's a significant number of donations each week, then I'd say it hasn't sold within 6 or 7 weeks, then pull it off, if there is consistently plenty more to go out.
For other categories and subjects, books might stay for a bit longer - there are some subjects for which we don't get consistently high donations each week, so if it's a case of having, for the time being, minimal stock of that subject, then better to let books stay on the shelf, even if they've been there for a while.
In the shop I'm in the managers and certain volunteers look up prices of items that appear as though they might be valuable. (Over time, you can develop a bit of an eye for judging whether something might potentially be more expensive.) If I'm unsure, I check anyway. Sometimes I've looked a book up and it's not been very expensive, other times, my "intuition" has been correct and it's been something around £50 (or higher.)