Fix memory leaks closing v1 hardware.
Fix memory leaks closing v1 hardware.

Thanks valgrind

12019/stlink,karlp/kkstm32_base,12019/stlink,swegener/stlink,braincorp/stlink,chaosAD/stlink,chaosAD/stlink,swegener/stlink,simonjwright/stlink,trigrass2/stlink,fedorcomander/stlink,ros2/stlink,gtalusan/stlink,simonjwright/stlink,ros2/stlink,fedorcomander/stlink,gtalusan/stlink,trigrass2/stlink,braincorp/stlink