I often get the gut-level feeling that a contestant who walks away on "Who Wants to be a Millionaire" is doing the wrong thing, so I decided to analyze the decisions mathematically and see what I can come up with. The first nontrivial level is the 2K one, so we start there.
My assumption will be that on average you have a 1/3 chance of getting a question right, up to the 50K level, when it drops to 1/4 because of the increased difficulty of the question.
2K, going for 4. Here you are risking 1K to win 2K, but we must factor in the additional chance of winning more than that. Thus, your true expected gain is 2 + 1/3x4 + 1/9x8, and I will stop there as this already gets us to about 4 as an expected gain. Hence you are risking 1 to win 4+, so you should always guess at the 2K level.
4K, going for 8. Here you are risking 3 to win 4 + 1/3x8 + 1/9x9 + 1/27x25. And again I stop here as we are at about 9 already, meaning you are risking 3 to win 9+, and should always guess here also.
8K, going for 16. Here you are risking 7 to win 8 + 1/3x9 + 1/9x25 + 1/36x50 + 1/144x150... This means you are risking 7 to win about 16, meaning you should go ahead and guess if you have it down to 2 choices. In reality this is often the case, and contestants often use their 50-50 here to get it down to 2 choices, but then they often walk away, which is a clear mistake as the odds say you should guess even if you have it down to 3 choices.
16K, going for 25. Here you are risking 15 to win 9 + 1/3x25 + 1/12x50 + 1/48x150 + 1/196x250. This means you are risking 15 to win about 22. The same comment applies here as at the least level. Contestants often get it down to 2 choices and then walk away. Mathematically, this is a clear mistake, although there are more legitimate arguments for walking at this level than at previous ones. It may be that the contestant really needs that 16K, but does not so much need the additional dollars.
25K, going for 50. This is a free guess so there is no walking away decision. However, there is another similar decision, which is whether to "walk away" from the question, since at this level you get the "switch the question" lifeline. IMO contestants too often switch the question at this level. It is a free guess, and I think if you can eliminate even one answer, then you should guess and save the lifeline for a future question.
50K, going for 100. Here you are risking 25 vs. 50 + 1/4x150 + 1/16x250 + 1/64x500. This adds up to 113, meaning the odds are clearly with you to guess, and you should always do so, even if you cannot eliminate any of the answers. Needless to say, contestants are much too risk-averse and often will walk away at this level when they should guess instead.
100K, going for 250. Here you are risking 75 to win 150 + 1/4x250 + 1/16x500. This is about 240, which again is more than 3 times the loss if you are wrong, so mathematically you should always guess, though as mentioned before more than math may come into play here.
For the last 2 questions the math is less of a factor, and other factors will determine whether you answer or walk.