Close p->mwf.fd only if necessary

This fixes a regression introduced in revision 9d2f841a5d39fc25ce722a3904f6ebc9aa112222.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
Merge pull request #1749 from csware/handle-fixes

Close p->mwf.fd only if necessary