Fix segfault caused by reading after shutdown