When that happens I walk away from the table, take a drink and refocus. Just like Fats did in the "Hustler". This usually happens because I get lazy and just shoot balls without thinking or planning or just being too confident and not respecting the shot. I find that is usually why I have a crappy game.
To correct this I slow down and make a plan for every shot before I start to shoot. This happened the other night. I was down 4 to 1 in a race to 5. I took my time, planned every shot and CB position and ended up winning the match. After winning 2 in a row it also affected the other player and he started to lose his confidence.