In order to discern the correct tense to be used in any sentence, we have to keep in mind two things - one, if the options provided make grammatical sense within the framework of the given sentence; and two whether the secondary action in the sentence has completed or is in the process of unfolding WITHIN the relevant timeframe. In this case, we see that his family joined him later, ruling out the present continuous tense Option C), and both Options A) and D) do not grammatically agree with the rest of the sentence as the former is present tense. This leaves us with Option B) - the correct answer, and of the past perfect continuous form - which is obtained by adding 'had been' to the base verb + ing. The verb in question is 'to live'; for which the base/ root form is simply 'live'. Applying the above, we clearly get 'had been living, which is the correct answer.