Almost certainly they were not correct. First of all, being an inpatient in a hospital does not make you a prisoner -- no competent adult can be forced to accept Medicare Part A covers a medically necessary inpatient hospital stay, as determined by the doctor who "admits" you to the hospital and by the hospital's medical review board. Medicare Part A, too, must agree that the inpatient stay is medically necessary. But the days of your inpatient stay would not retroactively become medically "unnecessary" just because you check yourself out before your doctor officially discharges you. If your stay in the hospital was appropriate in the first place, under Medicare Part A rules, that stay should be covered regardless of the circumstances of your discharge.
unwanted medical care, so if you choose to leave the hospital before your doctor discharges you, you have the right to do so.
There are a few circumstances in which a medical service might not be covered if a patient interrupts the care being provided. For example, if someone is undergoing physical testing or screening but leaves before it is completed, the office or clinic providing the care might bill the patient for the service but Medicare would refuse to pay its share of the bill. Or, if a patient is undergoing a treatment that must be completed in several stages but fails, without good reason, to complete the treatment, Medicare might refuse to pay its share of the bill. Unless some similar circumstance occurred regarding your hospital stay, Medicare Part A would have covered your inpatient care regardless of whether you waited for your doctor to discharge you.