Not sure where can be your problem without seeing your code. But after
net use \\192.168.1.45\ipc$
the following code
#include "windows.h"
void main(void){
WNetCancelConnection2("\\\\192.168.1.45\\ipc$",0,TRUE);
}
disconnects the resource without problems.