wrappers/cpp: Stop loop before clearing devices (prevents hang on exit) - fixes #295

Signed-off-by: Benn Snyder <benn.snyder@gmail.com>