// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { dcmotor.VelocityUpdate -= onVelocityUpdate; dcmotor.Close(); dcmotor = null; vol.VoltageRatioChange -= onVoltageRatioChange; vol.Close(); vol = null; Application.Quit(); } }