void OnApplicationQuit() { //Reset DMX levels to 0; for(int i=0; i< N_DMX_CHANNELS; i++) DMXLevels[i] = (byte)0x00; updateDMX = true; //Clean up dmxThread.Abort(); if (serialPort != null) { serialPort.Close(); serialPort.Dispose(); } } }