You can just put down stone traps and it will kill 85% of invasions. The rest you can create a drawbridge or something and pull it up if you see an enemy you can't deal with. Closing yourself off also means you can't trade, generally, so it's good to leave your fortress semi-open.