fix appium device end callback logic (fix #1389)