I have a custom statement that closes all the windows in a database except the active one. The code is short.
let otherwindows = arrayrange(info("windows"),2,-1,cr())
looparray otherwindows,cr(),otherwindow
if windowinfo(otherwindow,"database")=info("databasename")
// bring window forward, then close it
window otherwindow
closewindow
endif
endloop
This topic was discussed in an earlier post: Window Position with Initialize