Drawing circle in the thread happened to an error

I tried to draw circle in the thread , this is the code

from psychopy import visual,event,core,event
import threading
def demo():
    win = visual.Window()
    yuan = visual.Circle(win, radius=15, lineColor='red', fillColor='red', pos=(0, 0), units='pix')
    yuan.draw()
    win.flip()
    core.wait(6)
    win.close()
if __name__ == '__main__':
    t = threading.Thread(target=demo)
    t.start()

and this is the error I’m getting:

AttributeError: ‘NoneType’ object has no attribute ‘close’
Can you see what im doing wrong?
Thanks for your help!