Fixed shutdown on OSX.