Replaced time.sleep with delay
Added stop() function call on stopping user project