catch a gateway NoneType problem when shutting down.