I am sorry you are in a bit of a difficult situation.
As you clearly know when the lease runs out the tenancy becomes a month to month tenancy. To end the tenancy you need grounds. One ground is that you need the house for yourself or your family.
But another ground is that the new owner of the house needs the house for their family.
So you can go ahead and sell the house when the lease is coming to an end and then the tenants can be evicted so long as the new owners need the home for themselves.
There is no time limit in terms of your living there. It is all about what is honest and bona fide.
So if you move in and a short time later move out and they decide to take you to the landlord tenant board then you would have to show that you had planned on living there and something happened.
It is by far better not to take a chance and do this correctly by selling and then evicting for the new owner.
Does that answer your question?
Please feel free to post back with any follow-up questions you may have. If you don't have any then I hope I have earned a 5 star rating but if you don't feel that I have please don't hesitate to reply back and let me know what more I can do to assist you. Finally, please know that even after you rate me I will be here for you and you can ask follow-up questions if you think of them later on at no further charge of course.