Depends on the terms of your tenancy agreement, but it indeed is the case that the standard TA (which is what most people sign) simply means the tenancy gets transferred to the new
property owner, ie you get a new landlord.
There is someone who posted in another board whose agreement apparently requires him to vacate upon a sale. That is not the usual case though.
In your case, your only option is to speak with the new owner to see if they're agreeable to you moving out (maybe they plan to move in or something which would be great for you) or assigning what's left of your lease to someone else, again, only if they're agreeable.
Actually, for any tenancy agreement, anything goes if both parties are agreeable on anything or any terms that are not illegal.