When exiting while the miner is running, finding a block after the p2p layer has been shutdown will cause a crash as the now uninitialized p2p layer is asked to relay the found block to any peers.