Using foobar2000 Via wine as the Default Application for FLAC

In ~/bin, I created the following script

#!/bin/sh

if [ "$1" ]; then
audio_file="Z:`echo $1 | sed 's/\//\\\/g'`"
env WINEPREFIX="/home/seamonkey/.wine" wine \
"C:\\Program Files (x86)\\foobar2000\\foobar2000.exe" "$audio_file"
else
env WINEPREFIX="/home/seamonkey/.wine" wine \
"C:\\Program Files (x86)\\foobar2000\\foobar2000.exe"
fi

If foobar2000 is launched with this script and no arguments are passed, it launches and is able to exit cleanly. If I pass a file to it, it plays the file, but when I close foobar2000, I have to force quit the application. Any idea what I can do to get it to exit cleanly when a file is passed to it?