Merge pull request #505 from roji/shutdown_flow