REST API Shutdown improvements

Implements the comments from #161 (and depends on it)