Call stop() before setting run=0

The previous code was setting run = 0 and then calls stop().
stop() will not deinitialize anything due to the precondition that run != 0