Fixing a bug with return value comparison in stop() function