Before hanging up, I would try saying no in a very clear manner:
"[NAME], I'm really sorry but I cannot help you"
You start with their name in order to get their attention. You say that you're sorry as to be more polite. You explicitly say no ("I cannot help you") rather than implicitly saying no ("it's late") so that the message is clear.
This is particularly important when someone is distressed and they may miss these signals.
If that doesn't work, I'd go with a slightly modified version of John's suggestion:
"I'm really sorry [NAME], but I've got a long day tomorrow and I need
to go. I hope you find someone to help you. Good night!"
The main difference between my suggestions and John's is that you are suggesting that because it is late you have to go to sleep, while it John's it may be understood as you choosing to go to sleep as you haven't offered an excuse as to why you must do it. The person you are speaking to might infer that you are choosing to go to sleep to avoid having to speak to them.
That said, the best response also depends on your relationship with the other person and how honest you can be with them. I can imagine situations where it would be best to say,
"[NAME], I'm going to sleep"
Which would clearly indicate that they are annoying you to some degree. With the right person though, they will accept that they were being annoying and respect you for setting boundaries.