The best route, I believe, would probably be using OnClose.
OnClose is a callback which prolongs the server shutdown (by up to 30 seconds), giving you time to finish (or do) any saving which needs to be done. Doing it incrementally, as suggested by Fangous, wouldn't really be the best route. |