def program_exit(link, work_mode):
    if (work_mode == '1'):
        print('Saving last linear link position')
        open('last_link', 'w').write(link)
    print('Script stoped')
    sys.exit(0)
def program_exit(link, work_mode):
    if (work_mode == '1'):
        print('Saving last linear link position')
        open('last_link', 'w').write(link)
    print('Script stoped')
    sys.exit(0)