Stay as long as you're aware of three things:
1. If you are preventing other diners from sitting, maybe you need to go somewhere else to continue your conversation.
2. If you are preventing the restaurant from closing, maybe it's time to go home to bed.
3. If you are preventing the server from finishing his/her shift, give them the folder with the paid bill/tip and continue to enjoy the companionship of your friends - provided you don't violate & 1 and #2.