“‘Will you stop it?’ he demanded in a low impatient voice. ‘This isn’t the spot for the school-girl act. Listen to me. The pair of us are sitting under the gallows.’ He took hold of her wrists and made her stand up straight in front of him. ‘Talk!'”
Hammett, The Maltese Falcon, page 209
At the end of the day, being good or bad doesn’t matter- you just have to talk and try to get out as clean as possible. Spade’s choice in the end wasn’t a good one, but it was done in cunning because he knew it was the only way for him to get out. Also, at a certain point, pretending to be good and innocent does not work- your actions come up to get you (except if you’re Spade).