"detained at her Majesty's pleasure"

Max, you are quite right. The phrase does refer to an indeterminate sentence, usually for the criminally insane.

Rod