1- 'a la mierda' is used as 'Holy shit!' when used to express surprise.
2- 'a la mierda' can be used to say that one is 'getting the hell out of here'. You may also send someone 'to hell'.
Note: mierda means shit, so actually you're going and sending someone 'to the shit' when using 'a la mierda'.
Holy shit! I found a coin.
Me voy a la mierda, nos vemos.
I'm getting the hell out of here, see you.
Andate a la mierda!
Go to hell!
A variant is "andate a la mierda". Instead of talking about something as in "a la mierda" it talks about someone. His equal in english is "fuck off".
Matt: A la mierda, I don't wanna do it.