I have such an application for vibration measurement. To do a safe stop of
the hardware, avoiding untended reboots, screens of death, etc, I first
have:
ProcessSystemEvents(); // numerous, throughout the program,
then
DAQ_Clear(ADHardware.iDevice); // the hardware A/D writes to memory must
be stopped before memory is freed
then DiscardPanel () // assuming you want to do this
and then all dynamically allocated memory is freed .
This works cleanly.
Duncan