[bp=Pokémon_cloning#Generation_IV]Bulbapedia link[/bp]
It requires really good timing. You have to turn off the power before the game sends the data that a Pokémon has been withdrawn from the GTS to the GTS itself.
Thanks. Could you lose your pokemon if things go wrong then?