Both terminating and stopping has same code just change the method used.
import boto3
ids = ['i-0bec2a0bf000bb71c']
ec2 = boto3.resource('ec2')
ec2.instances.filter(InstanceIds = ids).stop() #for stopping an ec2 instance
ec2.instances.filter(InstanceIds = ids).terminate() #for terminating an ec2 instance