Fixes NRE on shutdown issue (https://trello.com/c/yaqBj7dW).