The filing of a petition in Bankruptcy triggers a section of the Bankruptcy Code called the "Automatic Stay"
In plain English, the "automatic stay" immediately prevents any creditor from filing a lawsuit against you, getting a judgment, repossessing your vehicle, foreclosing on your house, calling you, writing you, or communicating with you in any way. So even if the Judge is about to bang the gavel and find you liable on that $25,000.00 credit card debt, he can't do it if you've beat him to the punch by filing.
But the "automatic stay" doesn't last forever. In a Chapter 7, the debtor has 30 days to surrender the vehicle or "reaffirm" the debt (voluntarily enter into an agreement with the creditor to keep the vehicle and go back to making payments).
Similarly, in a chapter 13, the debtor can either surrender the vehicle or include it as part of a payback plan, requiring the debtor to stay current on new monthly payments and payoff any delinquencies over the length of the plan.
As with anything else, this not a full treatise on repossessions and the "automatic stay", but should give you enough information to get a general idea of how bankruptcy works.