I don't do small talk very well and I very quickly run put of things to say to someone I don't know so I don't like to just talk rubbish with someone, I prefer to remain quiet and get on with what I am doing.
I don't mean that the person isn't worth talking to or I don't like them, if they need something from me or have a question then I'll galdly answer or help them, but almost everyone takes it as a slight against them when i dont want to engage in idle chit chat and assume I'm an arsehole when I'm really not trying to be.
People don't need to talk to you if they don't want to People are so selfish just let people be some of use are on the spectrum and don't want to be forced into dumb conversations just because you can't be quite for a few hours
My trick is earbuds. Even if I'm not listening to anything. Also helps to be living in a country where you're not generally supposed to go talk to strangers