are you not getting any money from the sale?
if you plan to live in the new house for a very long time or forever then yeah thats fine, but if you are gonna be transient then no,
why would you put your life savings on a house you will only live in for a few years?
why are you selling the house? just get a property manager and rent out the house
are you switching jobs? you can only do 401k loans if you are working, you can still take out a loan before you leave the job but when you leave, whatever you owe on the loan will be taken out of your 401k principle
also you can take out a loan for any reason, so you can use it for a down payment, but the rule about using the 401k for a down payment is not a loan, its taken out your principle balance, essentially your are cashing out early without paying taxes on it