Fixed a crash of when restarting the emulator