How to detect if placing something would make pathing impossible?

I’m working on a tower defense game where towers can be placed on a grid and the enemies will path around the towers. How would I make it so that a tower can’t be placed where it would make it impossible to get to the end?

The screenshot below is what I’m trying to avoid.