memset(&jcr, 0, sizeof(jcr));
 
 
-#ifdef HAVE_WIN32
    WSA_Init();                       /* Initialize Windows sockets */
-#endif
 
    if (ndir > 1) {
       struct sockaddr_in client_addr;
       }
       UnlockRes();
       if (get_cmd(stdin, _("Select Director: "), UA_sock, 600) < 0) {
-        return 1;
+         WSACleanup();               /* Cleanup Windows sockets */
+         return 1;
       }
       item = atoi(UA_sock->msg);
       if (item < 0 || item > ndir) {
 /* Cleanup and then exit */
 static void terminate_console(int sig)
 {
+   WSACleanup();               /* Cleanup Windows sockets */
+
    static bool already_here = false;
 
    if (already_here) {               /* avoid recursive temination problems */
 
 {
 /* DWORD dwThreadID; */
    pthread_t tid;
-#ifdef HAVE_WIN32
    WSA_Init();
-#endif
    HINSTANCE hLib = LoadLibrary("KERNEL32.DLL");
    if (hLib) {
       p_GetFileAttributesEx = (t_GetFileAttributesEx)
    /* Call the "real" Bacula */
    BaculaMain(num_command_args, command_args);
    PostQuitMessage(0);
+   WSACleanup();
    _exit(0);
 }