By default SONAR stops playing or exporting when the last bit of data is encountered in the project. Projects which seem to play past the "end" of the project usually have automation nodes or MIDI past the "end" of the project.
Here is one solution to clean up the project
http://forum.cakewalk.com/FindPost/3205757 Another is visual inspection of the automation data and looking in the Event view for MIDI data.
Alternately, specific the time range to export. This can be done after selecting the tracks to export, drag across the time time or use the Select From/Thru or By Time or add markers to the project and select the time range based on the markers.
This is a question about SONAR usage; moved from Problem Reports to SONAR.