Add lock around managed ioloop starting

Might address some script-not-stopping-cleanly problems.