Stop process and reset count at end

This hopefully works in every situation. Tested it plenty. Not sure if
it will prevent overlapping processes though.