use SafeHandle to manage user32 lifecycle (fixes #1593)