The IabHelper example was updated to fix a number of bugs a couple of months ago, so first of all, be sure you have the latest version. I have used an earlier version and made various fixes of my own, so I can't say whether the latest one actually fixes this.
Here is an issue that was filed a while back regarding it:
https://code.google.com/p/android/issues/detail?id=41610
The general approach would be to copy and edit IabHelper, and in your own copy, test for a null value at the top of launchPurchaseFlow(). Something like this:
//If the service has somehow disconnected, then we cannot make the purchase
if(mService == null) {
result = new IabResult(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE,
"Unable to buy item because billing service disconnected unexpectedly.");
if (listener != null) listener.onIabPurchaseFinished(result, null);
flagEndAsync();
return;
}
...
Also, at the end of onServiceDisconnected(), you will want to abort any async operation that may have been interrupted by the disconnection of the service. Something like this:
boolean asyncWasInProgress = mAsyncInProgress;
if(asyncWasInProgress) {
flagEndAsync();
}
Hope that is helpful. IabHelper (at least the earlier version I used) has a number of bugs and so you can expect to come across this kind of thing, and such problems will need to be fixed when you do.