Fix potential crashes on close
Implement PowerNotifier for Windows