Set the app's timeout to 40 seconds (how depends how the app connects to SQL). What you ask is exactly what an application timeout is.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability