It's also interesting to note that Karl actually didn't lose at Poltava either. Due to his leg injury the overall command was held by Rehnskiöld.
In any case I think that locking him for 5 years just because of one battle or for failing to capture a certain city would be far too harsh.