It is not possible to hang up a call after a certain number of rings. The reason why is that the ringback tone which a user hears is produced by the carrier, not by Twilio.
When Twilio places a call, Twilio sends the carrier a message that simply says "play ringing now". The carrier will play ringing from the moment that message is received until either the phone picks up, or Twilio sends another message which indicates that ringing should stop.
Fortunately, it is possible to hang up a call after a certain number of seconds have elapsed using a "timeout" feature: