In most free-pathing TDs, the mobs attack the towers if they can't find a path through to the end. Usually, to prevent this being abused by the player to buy more time, those attacks are pretty brutal, and can wipe out a tower in a single attack.
To program this, I'd imagine something simple like, if the mobs can't find a path to the exit, find a path to the nearest tower and start pummelling it. Once it's destroyed, try find the exit path again, and so on until the player feels like an idiot for trying to screw your game :P
The other option is to prevent the player from putting down a blocking tower at all. In this case, just before you actually place down the tower (once it's been verified for position, cost, etc.), run a pathfinding action to see if a path is possible once the tower would be theoretically placed down. If it's not possible, prevent the tower from being placed.