Add missing call to CloseHandle on the win32 platform.

This fixes bug mirall#1236 and also mirall#1237
Also some minor cleanups.