Clean shutdown and startup of the indigo plugin.  Has to call into itself from the other thread so it can get the flask request context to set the shutdown flag.