Your tenancy hasn't yet ended, but you do need to give 2 months notice, as I think you realise. Most of your problem is with your friend who wishes to remain, and to minimise your own personal risk, you do need to confirm the end the tenancy now. Then it is up to her to find two new tenants to join her - there is nothing to prevent you helping her in this venture, but the risk is hers (if two new tenants are not found).
Doing it that way gets you out of the deposit situation.
Your friend cannot refuse point blank to end the tenancy - she will have no choice if you and the third person do so.