I am using a Canon 600D with it's inbuilt flash. When I try to take a photo in dim light using the flash, in Aperture priority mode, the camera chooses a very slow shutter speed. It seems as if it ignores the fact that I have the flash popped-up. This causes the resulting photo to look like 2 superimposed pictures, one nicely exposed via the flash, but the other image is like a ghost from when I inevitably move the camera a bit during the long exposure.

What is the right setup to take the photo?