external hard drive still shows in disk utility after it was removed
The correct command is given below.

diskutil eject disk3


You can also use the Finder and Disk Utility applications to eject a drive.

Occasionally, you may be using a drive that is not fully Mac compatible where the above command does not work. For example, I have an mp3 player that is not Mac compatible. When diskutil eject command is used, the player ejects only to remount a few seconds later. So, before removing the player from the USB port, I have to log out of my account to make sure all files are closed. In your case, you may have to shutdown the Mac before removing the drive.