A Simple Workaround
Are you experiencing issues with the LM Studio AppImage not fully closing on Linux? You’re not alone. We’ve created a simple and robust workaround that ensures all background processes are properly terminated when you exit the application.
This solution involves two Bash scripts: lmstudio-launch for launching the app cleanly, and lmstudio-shutdown for forcibly terminating any lingering LM Studio processes after you close the GUI.
What’s the Issue with LM Studio on Linux?
When closing LM Studio via its internal “Quit” menu or window closure, the main GUI disappears, but background processes such as LLM server components may remain running. This is a known bug in the LM Studio AppImage itself.
Our Solution – Two Simple Scripts
Instead of relying on the AppImage internal quit mechanism, we provide:
lmstudio-launch: A clean launcher script that starts the LM Studio AppImage.lmstudio-shutdown: A powerful script to forcefully terminate any lingering processes.
How to Set It Up
Step 1: Place the LM Studio AppImage
Download the LM Studio AppImage from LM Studio’s official website and place it in a dedicated directory, e.g., ~/lmstudio/.
Step 2: Create the Launch Script (lmstudio-launch)
Save this script at ~/lmstudio/scripts/lmstudio-launch with the following content:
#!/bin/bash
# Define the expected subdirectory for AppImages relative to the user's home
APPIMAGE_DIR="$HOME/lmstudio"
# Path to LM Studio AppImage
# Look for LM-Studio*.AppImage in the specified directory
APPIMAGE=$(ls "$APPIMAGE_DIR"/LM-Studio*.AppImage 2>/dev/null | head -n 1)
# Check if AppImage exists
if [ -z "$APPIMAGE" ]; then
echo "Error: No LM-Studio AppImage found in '$APPIMAGE_DIR'."
echo "Please ensure the LM Studio AppImage is placed in this directory."
exit 1
fi
# Optional: unset LD_PRELOAD to avoid memory library conflicts
unset LD_PRELOAD
# Launch with --no-sandbox (required for Electron in AppImage)
exec "$APPIMAGE" --no-sandboxMake it executable using:
chmod +x ~/lmstudio/scripts/lmstudio-launchStep 3: Create the Shutdown Script (lmstudio-shutdown)
Save this script at ~/lmstudio/scripts/lmstudio-shutdown with the following content:
#!/bin/bash
patterns=("lm-studio" ".lmstudio")
# Gracefully attempt to terminate all relevant processes
for pattern in "${patterns[@]}"; do
pkill -f "$pattern"
done
# Wait briefly for graceful shutdown
sleep 2
# Force kill any remaining processes
for pattern in "${patterns[@]}"; do
pids=$(pgrep -f "$pattern")
for pid in $pids; do
pkill -TERM -P "$pid" 2>/dev/null
kill -9 "$pid" 2>/dev/null
done
doneMake it executable using:
chmod +x ~/lmstudio/scripts/lmstudio-shutdownStep 4: Optional – Create Desktop Launchers (Recommended)
For convenience, you can create .desktop files for launching and shutting down LM Studio directly from your application menu.
Example lmstudio.desktop:
[Desktop Entry]
Name=LM Studio
Comment=Discover, download, and run local LLMs
Exec=/home/YOUR_USERNAME/lmstudio/scripts/lmstudio-launch
Icon=/home/YOUR_USERNAME/lmstudio/icons/lm-studio-icon.svg
Terminal=false
Type=Application
Categories=Utility;Development;AI;Example lmstudio-quit.desktop:
[Desktop Entry]
Name=Quit LM Studio
Comment=Forcefully terminate all LM Studio processes
Exec=/home/YOUR_USERNAME/lmstudio/scripts/lmstudio-shutdown
Icon=/home/YOUR_USERNAME/lmstudio/icons/lm-studio-shutdown-icon.svg
Terminal=false
Type=Application
Categories=Utility;Place these .desktop files in ~/.local/share/applications/ to make them appear in your application menu. You might need to log out and back in, or refresh your desktop environment’s menu cache for them to appear.
Important Note on pkill -f "lm-studio"
The shutdown script uses a forceful command to terminate processes. While this is effective, use it with caution and ensure you understand its implications.
Want to Help or Report an Issue?
Feel free to open issues or contribute improvements via pull requests on GitHub.
This project is open-source under the MIT License. You’re welcome to use, modify, and redistribute it freely.
Need a assistance with this kind of thing? Contact us to see how we can help.