<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def stop(self, spider_name=None):
 """Stop the named running spider, or the first spider found, if spider_name is None"""

        if spider_name is None:
            spider_name = self.spider_name
        else:
            self.spider_name = spider_name
        if self.spider_name is None:
            self.spider_name = self.list_running()[0].split(':')[-1]
        self.jsonrpc_call('crawler/engine', 'close_spider', self.spider_name)