the problem was with me.close() , it should be at the end with script.