Shutdown the Core before other components.

Other components depend on the EmuThread being stopped.
Merge pull request #616 from Armada651/shutdown

Shutdown the Core before other components.