Correct thread lock exception bug on quit, and correct a bug when removing a VM (next events were ignored)