Close Perspective Dock on Loss of Focus

I suspect part of the issue for you may be a bug that I also had noticed. Docked views aren't opening in modal correctly when they are set to modal if they are opened using a button. If it opened in modal correctly then it would close as soon as someone clicks outside of that docked view. There was another post like this. The bug is still open.