WASHINGTON (CNN) -- Closing the Guantanamo Bay, Cuba, detention facility is necessary and President Barack Obama's decision to set a one-year deadline on doing so was probably the only way to get it done, Defense Secretary Robert Gates said Tuesday.

Defense Secretary Robert Gates says setting a deadline is the only way to ensure Guantanamo Bay is closed.

"I believe that if we did not have a deadline, we could kick that can down the road endlessly," Gates said Tuesday afternoon before the House Armed Services Committee. "My experience in making anything work at the Department of Defense is, the only way I get anything done is by putting a deadline on it and making people understand that the deadline is meaningful."

Obama has been criticized by Sen. John McCain, R-Arizona, among others, for announcing a decision to close the detention facility before there were solid plans on what to do with those held there.

Gates said most of the detainees could either be tried or transferred elsewhere, leaving a small group whose circumstances are more difficult to figure out. But he said detainees would not be just let out.

"I can't imagine a situation in which detainees at Guantanamo who were considered a danger to the people of the United States would simply be released here," he said.