Reinstall El Capitan on 2009 iMac
Find your original installation (grey) DVD or acquire a DVD that is not bound to the machine (e.g. "Snow Leopard" DVD with the animal picture, not a grey CD).
Boot from the DVD
Using the disk utility (available from the DVD), fully erase the drive.
Install the original OS (e.g. "Snow Leopard 10.6.3")
If you installed snow Snow Leopard, get the "10.6.8" combo upgrade package and install it.
Search on Apple's site how to install OS X El Capitan on old MacBooks. I remember the link is not easy to find, but there's one. Download it and install it.