You should not leave the Synagogue, if this is at all possible, till there is no longer a Minyan there. In particular, you should not be the one to break the Minyan. Meaning, if there are only ten people left, you should not be the one to cause the departure of G-d's Holy Presence. Because the Shechinah departs when there is no longer a Minyan.
Now you might say this is very difficult because then nobody would leave and everyone would remain there. But that will not happen. The reality is that everybody is in such a rush in the morning, that before you know it there will no longer be a Minyan. You should if possible wait for that moment and especially not be the one to cause the departure of the Shechinah.
(See Ben Ish Hai, Shana Aleph, Parashath Miqqes, Oth Aleph)