use video_switch in your main function

eg

video_switch(7,0,1); makes the display 800x600(7) and fullscreen(1) change the 1 to 2 to take the display back to window mode.