
The guy's been having them the entire episode.
Hallucinations brought about by Post Traumatic Stress Disorder are delusions and symptoms of psychosis. In other words, Nicholas may be going crazy.
So it's totally possible that Nicholas just imagined the whole thing.
An interesting theory going around the web now is that right before Glenn and Nicholas climbed the dumpster, two clicking sounds were heard as Nicholas tried to fire his gun while Glenn was putting his away. This signifies that Nicholas is out of ammo.
So how could he have shot himself in the head, if he was out of ammo? Riiiiiight.
Michael Traynor, the actor who plays Nicholas says it's possible.
"That would be interesting. I mean, you know, with Tyreese's episode when he dies, there was this sort of strange fever dream, so it could all be a snapback. I think they're endlessly creative on the show, and they incorporate really complex devices to help tell an interesting story, so that's a possibility," said Traynor.