The blue flash during sunset is a relatively uncommon phenomenon. It appears just before the last rays of the Sun slip beneath an unobstructed horizon — where both the bending, or refraction, of light and mirage effects (multiple or inverted images) are greatest.
Astronomy magazine subscribers can read the full answer for free. Just make sure you're registered with the website.