@Sebastian
Tor has this functionality built-in, the timeout is configurable (30 seconds by default). Setting too long a timeout is bad if you're a guard, because the longer you wait to restart the more ?>clients will rotate away from you while you're down - just restarting without any timeout at all is rude for anyone currently having an active circuit, of course.
In short: The default is a sensible compromise, if you run a no-guard relay you can increase the timeout massively to be "nicer" to people with long-running connections, if you're a guard you probably shouldn't.
Can you provide explicit sequence of events/commands I need to execute for such graceful shutdown? Eg I need to reset my router - should I stop the tor service from Linux command line, , then check in tor log if it has finished its graceful shutdown, then reset router, then start tor again? Ir is there no need to even check the log?