To close vi the command :q should be issued. Plain q will get you out of top.
If those processes remain running after you've closed them, then use the kill command to shut them down. You can check for processes still running by issuing the command ps aux. Once this is done find the PID (Process ID), and use kill in this manner: kill -9 PID
If you do find for some reason that these programs are still running, even after you've shut them down with the proper command, then there is probably something wrong with your systems, and it might be your home directory since you saved that.