This tiny code will demonstrate how to log-off from windows.
Enjoy!

#include <windows.h>
#include <stdio.h>
int main (int argc, char **argv)
{
 printf ("Good-bye!\n");
 ExitWindows(0, 0);
 return 0;
}

With newer versions of windows you acn also use the "shutdown" command by calling system();