From what you've said, it must be crystal clear to you that he's done a real number on your son and if I were you I'd use every trick in the book to wipe the sneer off his face get your ds out of his clutches.
He's in urgent need of psychiatric assessment but, ime, these wily twats very often get away it.
Please bear in mind that he is likely to be hotfooting it to solicitors tomorrow and simply finding out where legal aid and a child residence order has been submitted isn't going to cut it.
You MUST apply for an occupation interdict and, depending on your new solicitor's advice, a prohibited steps or child residence interdict. Just think how you'd feel if you could waltz up to the marital home tomorrow, compel him to leave with MIL, and resume residence with your ds..... he could hardly take ds away from you as it's apparently the child's stated wish to remain in the house and in his own bedroom until it's sold, is it not?
You are your son's primary carer. As such you want to do the best for him and if this means giving him the stability he wants until such time as the house is sold then so be it. You'll suck it up and live there until the sale goes through.
The fact that he's changed the locks and is refusing/has failed to give you a set of keys should count against him and, hopefully, go some way to convince the Sheriff that he's not a reasonable man.
Given the events of the last 48 hours, your new solicitor should not have a problem finding grounds to support your applications. What I'm more worried about is whether you can find a solicitor who can act for you at short notice. Perhaps WA can advise?
Put any notion of an order to force a sale on ice until the above is sorted. If you can get an occupation interdict it will put you firmly in the driver's seat and you can bet that he'll be chasing for a quick sale because it'll drive him mad he won't want to see you living in what he clearly considers to be HIS house.
I'd also advise you to give consideration to proceeding with divorce at the earliest opportunity, otherwise this will be another occasion where he can get in first. As I understand it, and in accordance with the law of England/Wales, you can file your petition to divorce citing his unreasonable behaviour online for very little cost - I can at least help you to set out your grounds for divorce in a concise manner.
As I've made clear, I am not familiar with the laws of Scotland but it may be that if your solicitor makes mention of your intention to file for divorce in the near future, the Sheriff may see fit to grant interdict(s) until such time as child residency and other such matters are resolved as part and parcel of the divorce process. It may be worth a try and may go some way to maintain the narrative of your abuser as an unreasonable man who is intent on having his own way no matter how much unnecessary stress and trauma he causes others.
There's a lot to do and a lot to take in. There's also a lot to lose... don't be soft, harden your heart and play to win - your ds deserves nothing less.