Fixing the stop function to use the pidfiles created