Is it possible to disconnect a bluetooth connection using Applescript?
Here is what I use for disconnecting my Samsung Soundbar. Also remember that you need to give permission to application to use SystemUIServer steps for that.

System Preferences &gt; Security &amp; Privacy &gt; Accessibility &gt; [name_of_your_application]

One little remark: you need to have bluetooth icon on your menu bar.

tell application "System Events" to tell process "SystemUIServer"
    set bt to (first menu bar item whose description is "bluetooth") of menu bar 1
    click bt
    tell (first menu item whose title is "[Samsung] Soundbar") of menu of bt
        click
        tell menu 1
            if exists menu item "Disconnect" then
                click menu item "Disconnect"
            else
                click bt -- close main dropdown to clean up after ourselves
            end if
        end tell
    end tell
end tell