Bartolo realizes in the end that it is a trick , and gets everyone out of the room . He goes to a notary to get a marriage contract made between himself and Rosina . Finally Bartolo detects the trick , drives everybody out of the room , and rushes to a notary to draw up the marriage contract between himself and Rosina .