A bash utility to gracefully terminate Google Drive and all its related processes on macOS.
Sometimes Google Drive for desktop on macOS can become unresponsive or needs a complete restart. This script provides a clean, reliable way to shut down Google Drive and all its helper processes without leaving orphaned processes running in the background.
- Graceful Shutdown: Attempts to quit the app properly first using AppleScript
- Complete Cleanup: Terminates all related helper processes and extensions
- Safe Fallback: Uses SIGTERM first, then SIGKILL only if needed
- Process Verification: Confirms shutdown and reports any remaining processes
- Targeted Killing: Only targets Google Drive processes, not other applications
The script handles all Google Drive-related processes:
| Process | Description |
|---|---|
| Google Drive | Main application |
| Google Drive Helper | Primary helper process |
| Google Drive Helper (Renderer) | Electron renderer processes |
| Google Drive Helper (GPU) | GPU acceleration processes |
| crashpad_handler | Crash reporting (Google Drive instances only) |
| FinderSyncExtension | Finder integration (Google Drive instances only) |
# Clone or copy the script to your bin directory
cp kill-google-drive ~/bin/killgd/
# Make it executable
chmod +x ~/bin/killgd/kill-google-drive
# Add to PATH (add to ~/.zshrc or ~/.bashrc)
export PATH="$HOME/bin/killgd:$PATH"
# Command alias:
alias killgd="$HOME/bin/killgd/kill-google-drive"# Run the script directly
./kill-google-drive
# Or if added to PATH
kill-google-drive
# Or with alias
killgd$ killgd
Shutting down Google Drive...
Google Drive has been shut down successfullyOr if processes remain:
$ killgd
Shutting down Google Drive...
Warning: Some Google Drive processes may still be running:
12345 Google Drive Helper (GPU)- AppleScript Quit - Asks the app to quit gracefully via
osascript - SIGTERM - Sends termination signal to each process by exact name
- Wait Period - Gives processes 0.5 seconds to clean up
- SIGKILL - Forces termination if process is still running
- Verification - Waits up to 3 seconds and checks for remaining processes
- Uses exact process name matching (
-xflag) to avoid killing similar processes - Uses pattern matching for helper processes to target only Google Drive instances
- Graceful termination before forceful killing
- Silent operation when processes aren't running (no error messages)
- Final report of any processes that couldn't be terminated
- Bash 4.0 or higher
- macOS with Google Drive for desktop installed
- Standard Unix utilities:
pkill,pgrep,osascript,kill
The script uses set -euo pipefail for robust error handling:
-e- Exit on error-u- Exit on undefined variable-o pipefail- Catch errors in piped commands
- Google Drive becomes unresponsive or frozen
- Need to restart Google Drive completely
- Before system maintenance or updates
- When Google Drive sync is stuck
- After changing Google Drive settings that require restart
- When Finder integration stops working
# Restart Google Drive completely
killgd && sleep 2 && open -a "Google Drive"
# Add to a maintenance script
#!/bin/bash
echo "Restarting Google Drive..."
killgd
sleep 3
open -a "Google Drive"
echo "Google Drive restarted"Add to your ~/.zshrc or ~/.bashrc:
alias gd-restart='killgd && sleep 2 && open -a "Google Drive"'-
Data Safety: This script only terminates processes. Your synced files and data are not affected.
-
Sync Interruption: Any ongoing uploads/downloads will be interrupted and will resume when you restart Google Drive.
-
Graceful First: The script always tries to quit gracefully before forcing termination.
-
System Integration: Finder integration will be disabled until you restart Google Drive.
-
Permissions: No special permissions required (runs as current user).
If the script reports remaining processes:
- Wait a few more seconds and run the script again
- Check if Google Drive is protected by system security settings
- Manually terminate using Activity Monitor if needed
- Wait a few seconds after termination
- Open Google Drive from Applications folder or Spotlight
- If issues persist, restart your Mac
MIT License - Feel free to use and modify as needed.
Note: This script is designed specifically for Google Drive for desktop on macOS. It may not work with older Google Backup and Sync or on other operating systems.