If customer A is at the phase where they are entering credit card information (in the case of Stripe checkout), then I am not sure that there is anything that can be done because your in a part of the checkout process that is handled by Stripe.

One course of action that you could take is that when your stock quantity reaches 1, you could notify customers that there is a risk that someone else could purchase the product due to low quantity. OR simply put rules in place that when quantity is 1, set to zero when placed in customer B cart.