Fostering a child is highly recommended in Islam. Fostering a needy child or a needy orphan elevates the foster to high degrees in the Paradise as the Prophet Muhammad (SAWA) has reportedly said: Myself and a foster of an orphan are together in the Paradise like two fingers (the index finger and the middle).
Fostering person looks after the livelihood needs of the child which he/she wants to foster as far as he/she wants. In case for any reason, the person wants to stop his fostering, he can stop it and there is no legal obligation on him as the whole fostering is a voluntary noble act. Morally, the foster should do his best to look after his fostered child or look for a person who should look after the child in case he is unable to continue.
Wassalam.