Fixed NPE during application shutdown