The Court recalls that detention is authorised under subparagraph (b) of Article 5 § 1 only to ‘secure the fulfilment’ of the obligation prescribed by law. It follows that, at the very least, there must be an unfulfilled obligation incumbent on the person concerned, and the arrest and detention must be for the purpose of securing its fulfilment and must not be punitive in character. As soon as the relevant obligation has been fulfilled, the basis for detention under Article 5 § 1 (b) ceases to exist.
Source: official link