MainspringGuides › Disk in use
macOS Guide

Can't Eject a Disk Because It's in Use? Fix It on Mac

Updated July 2026 · 3 min read

You click eject and macOS refuses: "The disk wasn't ejected because one or more programs may be using it." Sometimes it names the app; usually it does not. Something genuinely has a file open on that drive, and there is a one-line Terminal command that tells you exactly what. Here is the fix, from polite to forceful.

Close the obvious suspects first

Most "in use" errors are caused by things you can see:

Then try ejecting again — select the drive and press Cmd+E. If it still refuses, stop guessing and ask the system.

Find the culprit with lsof

The lsof command lists open files. Pointed at the drive's mount point, it shows every process holding anything open there:

# list every process using the drive (quote names with spaces)
lsof +D "/Volumes/DriveName"

# include other users' and system processes
sudo lsof +D "/Volumes/DriveName"

The first column is the program's name, the second its process ID (PID). The command is read-only and can take a while on large drives — it is walking the whole volume. No output means nothing is holding files now; try ejecting again, since some locks are momentary.

Armed with a name, quit that app normally. If it is a background process with no window, quit it from Activity Monitor, or in Terminal:

# ask the process to quit cleanly
kill 12345

# if it ignores that, force it (unsaved work in it is lost)
kill -9 12345

One culprit deserves special mention: mds or mds_stores — Spotlight, busy indexing the drive. Give it a few minutes and it lets go on its own. If a drive you eject constantly is always being indexed, you can disable indexing for that volume with sudo mdutil -i off "/Volumes/DriveName" (undo later with sudo mdutil -i on "/Volumes/DriveName") — the trade-off is no Spotlight search on that drive.

Force Eject, the last resort

If the drive must come out now — laptop leaving, culprit unkillable — macOS offers force ejection: try the eject again and the failure dialog includes a Force Eject… button; the Terminal equivalent is diskutil unmount force "/Volumes/DriveName". Force ejecting while a program is mid-write can corrupt the files being written, and in bad cases the volume's directory — the same damage as yanking the cable, which is what you are doing, politely. Use it when you are confident nothing is actively writing (an indexing hang, a stale Finder lock), not while a copy dialog is on screen. A restart is the gentler nuclear option: it closes everything cleanly and unmounts all drives properly.

Whatever you do, wait for the drive's icon to disappear before unplugging. And if you slipped and pulled the cable early, plug it back in and run First Aid in Disk Utility to check the damage.

Fewer mysteries, more toggles

Troubleshooting drives isn't a one-click job — but tuning your Mac is. Mainspring turns 90+ hidden macOS settings into labelled, reversible toggles, from Finder behavior to power tweaks.

Try Mainspring free →

Signed & notarized by Apple · 1-day free trial · $29 once

The morning-after error

If your Mac greets you with "Disk not ejected properly" after every sleep, that is a different bug with its own fixes — usually the drive or hub dropping off during sleep. See fixing the disk-not-ejected-properly warning.