Check for drivers==NULL before trying to delete them at exit. This could happen if the emulator initialization failed for some reason and the drivers hadn't been initialized yet.