I think the other answers are ok but I just wanted to expand a little to try to give you a different point of view.
when one meets a stranger in the streets, for example, how would they
say “goodbye” to them?
As I said in a comment, this is not very clear. It could depend a lot on how the interaction goes on, what do you say, how old is the stranger compared to you etc.
However, what I want to say is: Don't assume you MUST say "goodbye" just because your native language/culture has taught you that it is the right thing to do.
A very important thing when learning a new language is to "get out" the mentality where you automatically port everything from your own culture.
Just as often "literal translation" does not work, the same is true for cultural habits.
Therefore, to go back to your question, don't think you necessarily have to say "goodbye", whether it is さようなら、では、じゃあ、またね, etc.
Depending on the conversation, it might be perfectly fine to just say nothing.
For example, the stranger asks you for an indication (how to go somewhere or find some place). Then, the conversation might just end with him thanking you, and you saying, いいえ or どういたしまして or whatever, and you both walk away. And that's perfectly fine.