This is a very difficult one.Sometimes there is no difference.
I think you can say "It was a sad movie- the hero dies in the end/at the end".Both sound ok to me.
"At the end" would sometimes be more physical, for example "At the end of my road there is a small shop" -here you cannot use in the end.
Also there are some fixed expressions "In the end, all that matters is that you are happy". You cannot use "at the end" here either.It is not a physical thing.