Add windows compatible check for parent process.

This is required to avoid holding on to a lock forever should
the parent process die or be killed. Based on code retrieved
here: http://stackoverflow.com/a/12518726/2092842