Have we run out of time in Afghanistan and Iraq?
Not likely. In Afghanistan, the USSR held out for a decade before being forced out — pretty much by the same people who are now working on us (the Taliban — who were our clients then). The Taliban are now staging something of a comeback, but they have almost five years to go before we reach the same temporal position the USSR was in when it finally withdrew.
For Iraq, we still have around six years to go.
We should, of course, remember what ultimately happened to the USSR when it was forced out of Afghanistan.