Fix Windows build: handles is declared after statement