Ants have three main types of suicidal defense mechanisms. Firstly, the ants can essentially 'blow' themselves up in a process called autothysis. This is where an ant will contract its abdominal muscle that surrounds a gland. This gland will then burst, spraying a toxic, sticky substance everywhere that can kill and/or immobilize its predator.
The second defense mechanism is where one to eight worker ants, will shut themselves out of the nest at night. This will prevent nocturnal predators from infiltrating the nest and it basically means that the ants are committing suicide because they rarely ever survive outside through the night.
The third suicide defense mechanism is a preventative strategy. When an ant can feel itself getting ill from some type of pathogenic disease, it will leave the nest and go and die in isolation, in order to prevent the rest of the colony getting ill.