What's the best way to safely stop/restart app?

Some method call will trigger a serials of db writes, and I don’t hope the app being interrupted at that time. So is there any mechanism to tell the app to stop receiving new coming method calls and restart the app after it finishing all received method calls?