handle NPE when shutting down