You can shrink the tempdb mdf/ldf files using the shrinkfile, shrinkdatabase DBCC commands.
use tempdb
go
dbcc shrinkfile (tempdev, 'target size in MB')
go
dbcc shrinkfile (templog, 'target size in MB')
go
Writing code in an efficient manner can avoid the growth of the tempdb. Avoid using "cursors" in your code which are major killers of performance and the larger the dataset of the cursor the larger the size of the tempdb. Avoid using temp tables when its not necassary. using #temptable, ##temptable for the entire scope when its not required will cause performance issues again.
SQL 2005/2008 has CTEs where in you can query data on a temp table and the scope is just one line after that.
;With CTETable as
(
SELECT <Columnlist> FROM <TableName> {Joins} WHERE <Condition> GROUP BY <Column List> ORDER BY <COlumn> ASC
)
SELECT ColumnList from CTETABLE
....
Statements
The scope of that CTEtable expires after "SELECT ColumnList from CTETABLE" Line. This way it is more effective. Writing effective queries would also help.