MPI_Win_free, as it name suggests, frees the resources behind an MPI_Win. It also returns a null handle, equal to MPI_WIN_NULL. MPI_Win_free is a collective operation; it must be called by all the MPI processes involved in the corresponding group. Each MPI process must call it only after it has completed all its pending RMA communications with that window.
Freeing a window that was created with a call to MPI_Win_create_dynamic detaches all associated memory. That is, MPI_Win_free has the same effect as if all attached memory was detached by calls to MPI_Win_detach.