the check variable has to be a global var in your example.

better solution:
use "proc_kill(4);" at the beginning of the cofunction. Read the manual entry about that function.