Suppose an enemy casts Time Stop and then makes an attack against me, rolling a 20 to hit against my 16 AC. Normally, I could cast Shield to cause this attack to miss. And of course, this attack also ends the Time Stop. So, does time start flowing "soon enough" for me to cast Shield against the attack that ends the Time Stop spell?
Yes, you can cast Shield
Time Stop says:
This spell ends if one of the actions you use during this period, or any effects that you create during this period, affects a creature other than you or an object being worn or carried by someone other than you.
As soon as the caster Attacks or creates some effect that affects a creature other than itself, the spell ends. Once the spell has ended, you can act normally, allowing you to cast Shield with your reaction, turning a potential hit into a miss.