I have gone through all my hard disks and found one that it wouldn't defrag or format. When I opened the case to disable it I found the main sata lead had worked out slightly, probably from when I took it in to get the new memory. To check it out I disabled the drive booted up and tried a normal shutdown, everything worked as it should. I knew then that it was that drive that is causing the problems.
I then plugged the drive back in and made sure the lead was fully home and had another go at reformatting it, it formatted no problem and with no errors and my machine now still shuts down and restarts.
I won't use the drive for anything important for the moment just see if I start to get bad shutdowns again and corrupted pagefiles if I don't then its possible that it was just the ribbon cable not fully in position.
Why are computers so frustrating.