Q. I cannot find anything about the subject of how long I may extend my shabbat? May I end shabbat (with maariv and havdala) at midnight for example? Is this discussed anywhere?
A. You can extend Shabbos until close to Chatzois (midnight), if you leave enough time, for praying Maariv and eating the Melaveh Malkah Seudah. Both should be carried out, primarily soon after the end of Shabbos or before midnight. It is only after the fact that you can do them until daybreak . (See O.C. 235,3 – Yisod Veshoresh Hoavodo, Megale Amukois).
Seifer Nishmas Shabbos quotes, the Arizal's opinion that the holiness of Shabbos does not depart until midnight. This also relates to until when should one wear Bigdey (clothing of) Shabbos. (See Mogen Avrohom 262,2)
Rabbi A. Bartfeld as advised by Horav Shlomo Miller Shlit"a