First of all a very intense scene,I was on verge when Nick was looking at the walkers, those eyes were so cold and scary. Nick was not a fighter like Rick, Glenn and others, he was just a common man living his shelf life in Alexandria safety.
Last season, he tried to kill Glenn. but it ends up with Glenn saving his ass from walkers. Glenn redeemed him at that point.
Yes. As messed up as he was, Nick was thankful to Glenn for redeeming him. So in the end, he said "THANK YOU" to Glenn for redeeming and providing him a second chance to fight and die for a cause. The episode name was also " Thank You" which is overshadowing the same.