def terminate_instance(instance, dryrun=True):
    """ Terminates instance.
    :param instance:                ec2.Instance
    :param dryrun:                  If True print instance that would be terminated
    """
    print('\nTerminating instances')
    if dryrun:
        print('Dryrun flag set. Would have terminated instance: ' +
            instance.instance_id)
        return
    instance.terminate()
    instance.wait_until_terminated()
    print('Instance terminated')
