I have read this question about how to euthanize a fish but I wonder what is the least painful way to kill shrimp?
Since invertebrates are different than fish I wonder if there is another way.
I think that freezing the shrimp would be the least painful. Put it in a bag of water, then refrigerate for about an hour, then freeze overnight.
And honestly some say that just putting it in a bag and stomping it or hitting it against the wall is a quick and painless way to euthanize the shrimp. I know stomping sounds horrible, but it is quick.
Here is a link to some suggestions: Euthanize a Shrimp
Also, some people have argued that shrimp and lobsters have such a small brain that their nervous system isn't complex enough to feel pain. Its more of a theory than a fact, though. It is hard to believe that a living animal could not feel pain.
The process might be irrelevant due to the brain size/incapacity to feel pain as pointed out in @MSU_Bulldog's answer.
Since precise cutting with a sharp blade into the brain is not an option as it is for fish, there remains
Both methods are recommended for fish as well.